Skip to content

Commit f94d0d9

Browse files
authored
Merge pull request #325 from iberryful/fix-gcp-svc
Refactor gcp service
2 parents af0f9b8 + e112d8b commit f94d0d9

File tree

5 files changed

+1112
-920
lines changed

5 files changed

+1112
-920
lines changed

src/services/gcp/Gopkg.lock

+76
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/services/gcp/cmd/gcp/main.go

+17-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"encoding/json"
55
"context"
6+
"os"
67
"runtime"
78
"os/exec"
89
"io/ioutil"
@@ -24,7 +25,7 @@ func printVersion() {
2425
func main() {
2526
printVersion()
2627

27-
gcpserviceaccount := "/var/run/infrabox.net/gcp/service_account.json"
28+
gcpserviceaccount := "/var/run/infrabox.net/gcp/service_account.json"
2829

2930
logrus.Info("Activating GCP service account")
3031
authCmd := exec.Command("gcloud", "auth", "activate-service-account", "--key-file", gcpserviceaccount)
@@ -57,10 +58,23 @@ func main() {
5758
if err != nil {
5859
logrus.Fatalf("Failed to get watch gcp: %v", err)
5960
}
60-
resyncPeriod := 5
61+
resyncPeriod := 20
6162
logrus.Infof("Watching %s, %s, %s, %d", resource, kind, namespace, resyncPeriod)
6263

63-
logrus.SetLevel(logrus.WarnLevel)
64+
logLevel := os.Getenv("LOG_LEVEL")
65+
66+
switch logLevel {
67+
case "debug":
68+
logrus.SetLevel(logrus.DebugLevel)
69+
case "info":
70+
logrus.SetLevel(logrus.InfoLevel)
71+
case "warn":
72+
logrus.SetLevel(logrus.WarnLevel)
73+
case "error":
74+
logrus.SetLevel(logrus.ErrorLevel)
75+
default:
76+
logrus.SetLevel(logrus.InfoLevel)
77+
}
6478

6579
sdk.Watch(resource, kind, namespace, resyncPeriod)
6680
sdk.Handle(stub.NewHandler())

src/services/gcp/infrabox-service-gcp/templates/deployment.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ spec:
2020
release: {{ .Release.Name }}
2121
spec:
2222
serviceAccountName: infrabox-service-gcp
23+
{{ if .Values.imagePullSecret }}
24+
imagePullSecrets:
25+
- name: {{ .Values.imagePullSecret }}
26+
{{ end }}
2327
containers:
2428
- name: {{ .Chart.Name }}
2529
command: ["./gcp"]
@@ -36,6 +40,8 @@ spec:
3640
value: infrabox-worker
3741
- name: MAX_NUM_CLUSTERS
3842
value: {{ .Values.max_clusters | quote }}
43+
- name: LOG_LEVEL
44+
value: {{ .Values.log_level | quote }}
3945
volumes:
4046
- name: service-account
4147
secret:

src/services/gcp/infrabox-service-gcp/values.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@ image:
44
repository: quay.io/infrabox/service-gcp
55
tag: latest
66

7+
imagePullSecret:
8+
79
max_clusters: 30
10+
11+
# info | debug | warn | error
12+
log_level: info

0 commit comments

Comments
 (0)