From 46e6e52845e2b9ee6e00bd46f20d072eeb382261 Mon Sep 17 00:00:00 2001 From: Jack Stockley Date: Tue, 22 Nov 2022 11:06:52 +0000 Subject: [PATCH] feat(helm): Update templates --- Dockerfile | 34 +++-- helm/cycling-blog/templates/cycling-app.yaml | 26 +--- .../templates/cycling-db-job.yaml | 63 ++++++++ helm/cycling-blog/templates/cycling-db.yaml | 26 +--- .../cycling-blog/templates/db-create-job.yaml | 44 ------ .../cycling-blog/templates/db-insert-job.yaml | 44 ------ helm/cycling-blog/values-dev.yaml | Bin 1723 -> 2061 bytes helm/cycling-blog/values-local.yaml | Bin 1446 -> 2476 bytes helm/cycling-blog/values-stg.yaml | Bin 1723 -> 2054 bytes helm/cycling-blog/values-test.yaml | Bin 1727 -> 2056 bytes po-lint/po-linter.go | 138 ------------------ 11 files changed, 96 insertions(+), 279 deletions(-) create mode 100644 helm/cycling-blog/templates/cycling-db-job.yaml delete mode 100644 helm/cycling-blog/templates/db-create-job.yaml delete mode 100644 helm/cycling-blog/templates/db-insert-job.yaml delete mode 100644 po-lint/po-linter.go diff --git a/Dockerfile b/Dockerfile index 80ec7fa..59dedce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,32 +1,40 @@ -FROM golang:1.17.8-alpine3.15 +FROM golang:1.19.3-alpine3.16 -RUN apk add git -RUN apk add postgresql-client +ENV \ + CGO_ENABLED=0 \ + GOOS=linux -RUN go get -u github.com/lib/pq -RUN go get -u github.com/joho/godotenv +RUN apk add postgresql-client RUN addgroup -g 1000 -S appgroup && \ adduser -u 1000 -S appuser -G appgroup WORKDIR /app -COPY . . +COPY go.mod /app +COPY go.sum /app +COPY main.go /app +COPY sql /app +COPY static /app +COPY templates /app +COPY .env_db /app +COPY .env_app /app + +RUN chown -R appuser:appgroup /app +RUN chown -R appuser:appgroup /go/bin +USER 1000 + +RUN go mod download RUN echo ${PGPASSFILE} > /home/appuser/.pgpass && \ chown appuser:appgroup /home/appuser/.pgpass && \ chmod 0600 /home/appuser/.pgpass - -RUN chown -R appuser:appgroup /app -RUN chown -R appuser:appgroup /go - -USER 1000 # Build the Go app -RUN go build -o main . +RUN go build -ldflags "-s -w" -o /go/bin/cycling_blog -buildvcs=false # Expose port 8080 to the outside world EXPOSE 8080 # Command to run the executable -CMD ["./main"] +CMD ["cycling_blog"] diff --git a/helm/cycling-blog/templates/cycling-app.yaml b/helm/cycling-blog/templates/cycling-app.yaml index eea62f7..f491c60 100644 --- a/helm/cycling-blog/templates/cycling-app.yaml +++ b/helm/cycling-blog/templates/cycling-app.yaml @@ -6,7 +6,7 @@ metadata: labels: app: {{ .Values.app_deployment.app }} spec: - replicas: 1 + replicas: {{ .Values.app_deployment.replicas }} selector: matchLabels: app: {{ .Values.app_deployment.app }} @@ -29,24 +29,10 @@ spec: ports: - containerPort: {{ .Values.app_service.ports.port }} env: - - name: PGPASSFILE + {{- range .Values.db_env }} + - name: {{ .name }} valueFrom: secretKeyRef: - name: pgpass - key: connect - - name: POSTGRES_USER - valueFrom: - secretKeyRef: - name: pgpass - key: username - - name: PGPASSWORD - valueFrom: - secretKeyRef: - name: pgpass - key: password - - name: POSTGRES_DB - valueFrom: - secretKeyRef: - name: pgpass - key: db_name - \ No newline at end of file + name: {{ .secretName }} + key: {{ .key }} + {{- end }} \ No newline at end of file diff --git a/helm/cycling-blog/templates/cycling-db-job.yaml b/helm/cycling-blog/templates/cycling-db-job.yaml new file mode 100644 index 0000000..9f6dc03 --- /dev/null +++ b/helm/cycling-blog/templates/cycling-db-job.yaml @@ -0,0 +1,63 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ .Values.cycling_blog_db_create.name }} + namespace: {{ .Values.namespace }} + labels: + app: {{ .Values.cycling_blog_db_create.app }} + annotations: + # This is what defines this resource as a hook. Without this line, the + # job is considered part of the release. + "helm.sh/hook": post-install + "helm.sh/hook-weight": "5" + "helm.sh/hook-delete-policy": {{ .Values.annotations.hookDeletePolicy }} +spec: + template: + spec: + containers: + - name: {{ .Values.cycling_blog_db_create.app }} + image: {{ .Values.app_deployment.template.containers.image }} + imagePullPolicy: {{ .Values.cycling_blog_db_create.template.containers.imagePullPolicy }} + command: ["psql"] + args: ["-h", "$(CYCLING_BLOG_DB_SERVICE_SERVICE_HOST)", "-U", "$(POSTGRES_USER)", "-d", "$(POSTGRES_DB)", "-w", "-a", "-f", "sql/create_table.sql"] + env: + {{- range .Values.db_env }} + - name: {{ .name }} + valueFrom: + secretKeyRef: + name: {{ .secretName }} + key: {{ .key }} + {{- end }} + restartPolicy: {{ .Values.cycling_blog_db_create.template.restartPolicy }} +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ .Values.cycling_blog_db_insert.name }} + namespace: {{ .Values.namespace }} + labels: + app: {{ .Values.cycling_blog_db_insert.app }} + annotations: + # This is what defines this resource as a hook. Without this line, the + # job is considered part of the release. + "helm.sh/hook": post-install + "helm.sh/hook-weight": "10" + "helm.sh/hook-delete-policy": {{ .Values.annotations.hookDeletePolicy }} +spec: + template: + spec: + containers: + - name: {{ .Values.cycling_blog_db_insert.app }} + image: {{ .Values.app_deployment.template.containers.image }} + imagePullPolicy: {{ .Values.cycling_blog_db_insert.template.containers.imagePullPolicy }} + command: ["psql"] + args: ["-h", "$(CYCLING_BLOG_DB_SERVICE_SERVICE_HOST)", "-U", "$(POSTGRES_USER)", "-d", "$(POSTGRES_DB)", "-w", "-a", "-f", "sql/table_insert.sql"] + env: + {{- range .Values.db_env }} + - name: {{ .name }} + valueFrom: + secretKeyRef: + name: {{ .secretName }} + key: {{ .key }} + {{- end }} + restartPolicy: {{ .Values.cycling_blog_db_insert.template.restartPolicy }} \ No newline at end of file diff --git a/helm/cycling-blog/templates/cycling-db.yaml b/helm/cycling-blog/templates/cycling-db.yaml index 3120e34..41d187b 100644 --- a/helm/cycling-blog/templates/cycling-db.yaml +++ b/helm/cycling-blog/templates/cycling-db.yaml @@ -28,24 +28,10 @@ spec: ports: - containerPort: {{ .Values.db_service.ports.port }} env: - - name: POSTGRES_USER - valueFrom: + {{- range .Values.db_env }} + - name: {{ .name }} + valueFrom: secretKeyRef: - name: pgpass - key: username - - name: POSTGRES_PASSWORD - valueFrom: - secretKeyRef: - name: pgpass - key: password - - name: POSTGRES_DB - valueFrom: - secretKeyRef: - name: pgpass - key: db_name - - name: HOSTNAME - valueFrom: - secretKeyRef: - name: pgpass - key: hostname - + name: {{ .secretName }} + key: {{ .key }} + {{- end }} diff --git a/helm/cycling-blog/templates/db-create-job.yaml b/helm/cycling-blog/templates/db-create-job.yaml deleted file mode 100644 index 1b0ec28..0000000 --- a/helm/cycling-blog/templates/db-create-job.yaml +++ /dev/null @@ -1,44 +0,0 @@ -apiVersion: batch/v1 -kind: Job -metadata: - name: cycling-blog-app-create - namespace: {{ .Values.namespace }} - labels: - app: cycling-blog-app - annotations: - # This is what defines this resource as a hook. Without this line, the - # job is considered part of the release. - "helm.sh/hook": post-install - "helm.sh/hook-weight": "5" - "helm.sh/hook-delete-policy": hook-succeeded -spec: - template: - spec: - containers: - - name: cycling-blog-app - image: jackstock8904/cycling-blog:latest - imagePullPolicy: Always - command: ["psql"] - args: ["-h", "$(CYCLING_BLOG_DB_SERVICE_SERVICE_HOST)", "-U", "$(POSTGRES_USER)", "-d", "$(POSTGRES_DB)", "-w", "-a", "-f", "sql/create_table.sql"] - env: - - name: PGPASSFILE - valueFrom: - secretKeyRef: - name: pgpass - key: connect - - name: POSTGRES_USER - valueFrom: - secretKeyRef: - name: pgpass - key: username - - name: PGPASSWORD - valueFrom: - secretKeyRef: - name: pgpass - key: password - - name: POSTGRES_DB - valueFrom: - secretKeyRef: - name: pgpass - key: db_name - restartPolicy: Never \ No newline at end of file diff --git a/helm/cycling-blog/templates/db-insert-job.yaml b/helm/cycling-blog/templates/db-insert-job.yaml deleted file mode 100644 index 454cd12..0000000 --- a/helm/cycling-blog/templates/db-insert-job.yaml +++ /dev/null @@ -1,44 +0,0 @@ -apiVersion: batch/v1 -kind: Job -metadata: - name: cycling-blog-app-insert - namespace: {{ .Values.namespace }} - labels: - app: cycling-blog-app - annotations: - # This is what defines this resource as a hook. Without this line, the - # job is considered part of the release. - "helm.sh/hook": post-install - "helm.sh/hook-weight": "10" - "helm.sh/hook-delete-policy": hook-succeeded -spec: - template: - spec: - containers: - - name: cycling-blog-app - image: jackstock8904/cycling-blog:latest - imagePullPolicy: Always - command: ["psql"] - args: ["-h", "$(CYCLING_BLOG_DB_SERVICE_SERVICE_HOST)", "-U", "$(POSTGRES_USER)", "-d", "$(POSTGRES_DB)", "-w", "-a", "-f", "sql/table_insert.sql"] - env: - - name: PGPASSFILE - valueFrom: - secretKeyRef: - name: pgpass - key: connect - - name: POSTGRES_USER - valueFrom: - secretKeyRef: - name: pgpass - key: username - - name: PGPASSWORD - valueFrom: - secretKeyRef: - name: pgpass - key: password - - name: POSTGRES_DB - valueFrom: - secretKeyRef: - name: pgpass - key: db_name - restartPolicy: Never \ No newline at end of file diff --git a/helm/cycling-blog/values-dev.yaml b/helm/cycling-blog/values-dev.yaml index 8f66d24aeed97904a755caeeecfa474e8094d639..50c0ee593b1d8759986bd3c7ab230f95fe6e003c 100644 GIT binary patch literal 2061 zcmV+o2=ey;M@dveQdv+`00c>-dQA_}6lw)*1O8O1ve{0$-5=uDt~LgyWa9vRV|Sls z^x^iJG!&rSUi>6r&u)j$hI=9Xv`>z;|y9pj}i3TJ%+6yZqE zD%A)guLcrNsg6_hT-W8C{2z1Kgg}N{SIYKyx2i7J|2GtBxp5_PL3suZVtgxTnVz<` zZZM*5FB(+B2{7wKZ~?jAfV^Y>+aLXMRTJ_Y=`1p+{<{mY3)gM1PHl1P)JkH?{g2DU z9~{p+(2Ae#JuC+X+fKi(4c}ku`65YA?DmhflKk_fhmAu7-1(waOO(lDsyY2xurC_^H}-H1+mo3s{!u z1(IS!A6o`TA!O;rM;PD6kqcH_@1r>Zym}-&P=zoY&_jY7YhF^W_uF31 zx6a(%N&MBeKU{G6Gc_B4lw8A=`awHN*O2J$?Qk4x|N9^8IStSUX%9X>BFr?yRR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+3x)w;rj&$L z5Xac6kWhCu9Q&ZQD+FUh>WR^%p=5t8n)qJT(t!VU?JuJvZsv}F)Cr%>3*Q{qq%BfBm1}t5ey+}+B}eEXA0+q|U>EHA z?KF)(z7_}JS(A-L6=XvM?X^oTQMYfSHwn_S)8HDs0uWmhi(kVEbA}NB2265`uB@nH zC|h%XVM2)Kh-_gawcVQ9e!9jA91bM|9nHgcjk&KQ@}+h6+j-F^mo3L)V0{~)>j>3C z_+G*`^%645KKm=2ip}PX+%BnN%A^sraA*H7{CMN4QX^OBLb66x1s5y5`9i@x6{%>& z6!&=6J95zuagtO1#dIX3M5kW<3$mTwm4BP9yxOam^`<`Zl5ZxhQ{FOMGaAQxI!R_qk@)-(_Rl6+z^F#cGM8%?*5>T`oCCOmE$y`Gy z&$MN-M;G4n1}OG z4CE8WG*)CwSK!B7(a$vE8E9N?tiZXGg@0HNjjlfisBf@pJrho**J}2@Y*|TV&Fci+ z`94&m}hS}XrXd0tYy8t0Hy*P_AnoL?JJOS(U+ncm^ zbJ1d!lsLtZEMZZJQqDZ)|7)o#0PMUrPW0 diff --git a/helm/cycling-blog/values-test.yaml b/helm/cycling-blog/values-test.yaml index 2cdb8ef185ab3a6b43a736ac608a124e58c2e536..c650adad08cad29864341aba8b894030ce78cd8a 100644 GIT binary patch literal 2056 zcmV+j2>15@M@dveQdv+`0K?-|?UIvWZ3lOxscy>n|6vs5iy3EG(X?-u1i+kGuC>oe z(o?vH{Bj9G{CgzY2n;H2!&J_=dudWs117^m1L@x?8guB0C`sv=B0-xyW5;}h5j)s` zhzZJ3UMZ|gc!hr&%ArRuSn1=K5Z^puv2Ow=yZ3CW=P({oWn#`_d~0N*Tw5N)wFz6S zd9oy0J2`V!Oa8{omO4WLxy&CSEEmeKL1-;A6Z_a=YONXHAgmvdm5%(bY2EuNLLc$)X0MR$fKS3Dxlf zddyz2o%Iq>yVd9aJ)6G&P}L>-ltrFmTC1n5+X@Lvi`MYo>26qq0dwS^w>3KnHhK~? z2A%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M&?q%R(MkTPA@ z5~l6PhG!>G5-Y3ofi>|X!mSuc^_E-USXaS7br%ObfUD`pFtj5zdtk+W_u}DCB6WBm z0rYnNLxoxDU>q~9snaunVXTDD?CNH@s}dhmHW)WUtF?C--Y@|;bGLN_1r4?*5n(BGKkg4kzT$KfLqq3s@zaYPE+hj1sw9u5(?&nhN~-4dtK46iPbQsSG|DTC z57P>%Syc1x7bt2tmKGTW|kp^U-CbP(v*-xIZRi%)*YIRl+D*LBO$SQB~Qc@3w@@@ci2NGG_w4ASsMS%+w|g2 zUWY9~w|)KrZAHO{V(5G^e>eSwyhTqi&BtrI_R{eJfw4X`DR`2s_iEwNba!Xhe$Rcz zL13C3vlke{y^L4#mIc(fGt^TP36;~yJoR{nyx2vLoZ_3yVx2YNa2yxoQ!ToO z`!4WjgK^F}6NIFG(T6i_@aNjzvt0xFTIgHO-XrVjC+EoATTpw~9Fnv_7D3fC=YW`5 VHrBlQo&vJvCtAM5M(LIDk&$i7Rn!0g diff --git a/po-lint/po-linter.go b/po-lint/po-linter.go deleted file mode 100644 index ee0399c..0000000 --- a/po-lint/po-linter.go +++ /dev/null @@ -1,138 +0,0 @@ -package main - -import ( - "bytes" - "context" - "encoding/json" - "errors" - "flag" - "fmt" - "io/ioutil" - "log" - "os" - "strconv" - "strings" - - "github.com/ghodss/yaml" - "github.com/ministryofjustice/cloud-platform-environments/pkg/authenticate" - "github.com/prometheus-operator/prometheus-operator/pkg/admission" - v1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" - "github.com/prometheus/prometheus/model/rulefmt" - githubaction "github.com/sethvargo/go-githubactions" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -func prDir(token, githubrepo, githubref string) ([]string, error) { - if token == "" { - return nil, errors.New("you must have a valid GitHub token") - } - - client, err := authenticate.GitHubClient(token) - if err != nil { - return nil, err - } - - //repo user and repo name - githubrepoS := strings.Split(githubrepo, "/") - owner := githubrepoS[0] - repo := githubrepoS[1] - - // get pr owner - githubrefS := strings.Split(githubref, "/") - branch := githubrefS[2] - bid, _ := strconv.Atoi(branch) - - repos, _, _ := client.PullRequests.ListFiles(context.Background(), owner, repo, bid, nil) - - var fileDir []string - for _, repo := range repos { - if strings.Contains(*repo.Filename, "kubectl_deploy") { - fileDir = append(fileDir, *repo.Filename) - } - } - return fileDir, nil - -} - -func polint(dir []string) { - files := dir - - for _, filename := range files { - log.SetPrefix(fmt.Sprintf("%s: ", filename)) - content, err := ioutil.ReadFile(filename) - if err != nil { - log.Fatal(err) - } - - var meta metav1.TypeMeta - - err = yaml.Unmarshal(content, &meta) - if err != nil { - log.Fatal(err) - } - - switch meta.Kind { - case v1.PrometheusRuleKind: - j, err := yaml.YAMLToJSON(content) - if err != nil { - log.Fatalf("unable to convert YAML to JSON: %v", err) - } - - decoder := json.NewDecoder(bytes.NewBuffer(j)) - decoder.DisallowUnknownFields() - - var rule v1.PrometheusRule - err = decoder.Decode(&rule) - if err != nil { - log.Fatalf("prometheus rule is invalid: %v", err) - } - err = validateRules(content) - if err != nil { - o := fmt.Sprintf("prometheus rule validation failed: %v", err) - githubaction.SetOutput("po-linter", o) - log.Fatalf("prometheus rule validation failed: %v", err) - } - default: - log.Print("MetaType is unknown to linter. Not in PrometheusRule") - } - } -} - -func validateRules(content []byte) error { - rule := &admission.PrometheusRules{} - err := yaml.Unmarshal(content, rule) - if err != nil { - return fmt.Errorf("unable load prometheus rule: %w", err) - } - rules, errorsArray := rulefmt.Parse(rule.Spec.Raw) - if len(errorsArray) != 0 { - for _, err := range errorsArray { - log.Println(err) - } - return errors.New("rules are not valid") - } - if len(rules.Groups) == 0 { - return errors.New("no group found") - } - for _, group := range rules.Groups { - if len(group.Rules) == 0 { - return fmt.Errorf("no rules found in group: %s: %w", group.Name, err) - } - } - return nil -} - -var ( - token = flag.String("token", os.Getenv("GITHUB_OAUTH_TOKEN"), "GihHub Personel token string") - githubrepo = flag.String("githubrepo", os.Getenv("GITHUB_REPOSITORY"), "Github Repository string") - githubref = flag.String("githubref", os.Getenv("GITHUB_REF"), "Github Respository PR ref string") -) - -func main() { - d, err := prDir(*token, *githubrepo, *githubref) - if err != nil { - log.Fatal(err) - } - polint(d) - -}