Skip to content

Commit bc1087e

Browse files
authored
Merge pull request #51 from MegaByte875/suppport_certs_env
get certs from env
2 parents 80d4ab6 + d34e660 commit bc1087e

File tree

3 files changed

+21
-62
lines changed

3 files changed

+21
-62
lines changed

Dockerfile

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
FROM ubuntu:20.04
22

3-
ENV LOGROTATE_ROTATE=5 \
4-
LOGROTATE_SIZE=100M \
5-
TZ=Asia/Shanghai
6-
73
RUN mkdir -p /usr/local/nebula/bin \
84
&& mkdir -p /usr/local/certs
9-
RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime \
10-
&& echo $TZ > /etc/timezone
115
RUN apt-get update \
12-
&& apt-get install -y --no-install-recommends ca-certificates curl cron logrotate \
6+
&& apt-get install -y --no-install-recommends ca-certificates curl \
137
&& apt-get clean all
148
COPY bin/agent /usr/local/bin/agent
15-
COPY db_playback /usr/local/nebula/bin/db_playback
16-
COPY logrotate.sh /logrotate.sh
17-
RUN echo "0 * * * * root /etc/cron.daily/logrotate" >> /etc/crontab
9+
COPY db_playback /usr/local/nebula/bin/db_playback

cmd/agent.go

+19
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"crypto/tls"
55
"flag"
66
"net"
7+
"os"
78

89
log "github.com/sirupsen/logrus"
910
"google.golang.org/grpc"
@@ -16,6 +17,12 @@ import (
1617
pb "github.com/vesoft-inc/nebula-agent/v3/pkg/proto"
1718
)
1819

20+
const (
21+
CACertPathEnv = "CA_CERT_PATH"
22+
ClientCertPathEnv = "CLIENT_CERT_PATH"
23+
ClientKeyPathEnv = "CLIENT_KEY_PATH"
24+
)
25+
1926
var (
2027
GitInfoSHA string
2128
)
@@ -47,6 +54,14 @@ func main() {
4754
// set agent rate limit
4855
limiter.Rate.SetLimiter(*ratelimit)
4956

57+
if os.Getenv(CACertPathEnv) != "" &&
58+
os.Getenv(ClientCertPathEnv) != "" &&
59+
os.Getenv(ClientKeyPathEnv) != "" {
60+
caPath = stringPtr(os.Getenv(CACertPathEnv))
61+
certPath = stringPtr(os.Getenv(ClientCertPathEnv))
62+
keyPath = stringPtr(os.Getenv(ClientKeyPathEnv))
63+
}
64+
5065
// set db_playback tls config
5166
clients.InitPlayBackTLSConfig(*caPath, *certPath, *keyPath, *enableSSL)
5267

@@ -93,3 +108,7 @@ func main() {
93108
pb.RegisterStorageServiceServer(grpcServer, server.NewStorage())
94109
grpcServer.Serve(lis)
95110
}
111+
112+
func stringPtr(s string) *string {
113+
return &s
114+
}

logrotate.sh

-52
This file was deleted.

0 commit comments

Comments
 (0)