Skip to content

Commit

Permalink
Merge pull request #325 from iberryful/fix-gcp-svc
Browse files Browse the repository at this point in the history
Refactor gcp service
  • Loading branch information
ib-steffen authored Jul 25, 2019
2 parents af0f9b8 + e112d8b commit f94d0d9
Show file tree
Hide file tree
Showing 5 changed files with 1,112 additions and 920 deletions.
76 changes: 76 additions & 0 deletions src/services/gcp/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions src/services/gcp/cmd/gcp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"encoding/json"
"context"
"os"
"runtime"
"os/exec"
"io/ioutil"
Expand All @@ -24,7 +25,7 @@ func printVersion() {
func main() {
printVersion()

gcpserviceaccount := "/var/run/infrabox.net/gcp/service_account.json"
gcpserviceaccount := "/var/run/infrabox.net/gcp/service_account.json"

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

logrus.SetLevel(logrus.WarnLevel)
logLevel := os.Getenv("LOG_LEVEL")

switch logLevel {
case "debug":
logrus.SetLevel(logrus.DebugLevel)
case "info":
logrus.SetLevel(logrus.InfoLevel)
case "warn":
logrus.SetLevel(logrus.WarnLevel)
case "error":
logrus.SetLevel(logrus.ErrorLevel)
default:
logrus.SetLevel(logrus.InfoLevel)
}

sdk.Watch(resource, kind, namespace, resyncPeriod)
sdk.Handle(stub.NewHandler())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ spec:
release: {{ .Release.Name }}
spec:
serviceAccountName: infrabox-service-gcp
{{ if .Values.imagePullSecret }}
imagePullSecrets:
- name: {{ .Values.imagePullSecret }}
{{ end }}
containers:
- name: {{ .Chart.Name }}
command: ["./gcp"]
Expand All @@ -36,6 +40,8 @@ spec:
value: infrabox-worker
- name: MAX_NUM_CLUSTERS
value: {{ .Values.max_clusters | quote }}
- name: LOG_LEVEL
value: {{ .Values.log_level | quote }}
volumes:
- name: service-account
secret:
Expand Down
5 changes: 5 additions & 0 deletions src/services/gcp/infrabox-service-gcp/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@ image:
repository: quay.io/infrabox/service-gcp
tag: latest

imagePullSecret:

max_clusters: 30

# info | debug | warn | error
log_level: info
Loading

0 comments on commit f94d0d9

Please sign in to comment.