Skip to content

Commit 7599c6e

Browse files
2 parents 149ac2c + cc89f6e commit 7599c6e

File tree

9 files changed

+213
-187
lines changed

9 files changed

+213
-187
lines changed

chart/ms-validate-user/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

chart/ms-validate-user/Chart.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: ms-compitem-crud
3+
description: Dependency Packages
4+
type: application
5+
version: 0.1.0
6+
appVersion: "1.0"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "ms-compitem-crud.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "ms-compitem-crud.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "ms-compitem-crud.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "ms-compitem-crud.name" . }}
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: {{ include "ms-compitem-crud.name" . }}
10+
tier: backend
11+
track: stable
12+
template:
13+
metadata:
14+
labels:
15+
app: {{ include "ms-compitem-crud.name" . }}
16+
tier: backend
17+
track: stable
18+
spec:
19+
containers:
20+
- name: {{ include "ms-compitem-crud.name" . }}
21+
image: "{{ .Values.DockerRepo }}:{{ .Values.DockerTag }}"
22+
imagePullPolicy: Always
23+
env:
24+
- name: DB_USER
25+
valueFrom:
26+
secretKeyRef:
27+
name: pgcred
28+
key: DBUserName
29+
- name: DB_PASS
30+
valueFrom:
31+
secretKeyRef:
32+
name: pgcred
33+
key: DBPassword
34+
- name: DB_HOST
35+
valueFrom:
36+
secretKeyRef:
37+
name: pgcred
38+
key: DBHost
39+
- name: DB_PORT
40+
valueFrom:
41+
secretKeyRef:
42+
name: pgcred
43+
key: DBPort
44+
- name: DB_NAME
45+
valueFrom:
46+
secretKeyRef:
47+
name: pgcred
48+
key: DBName
49+
ports:
50+
- name: http
51+
containerPort: 80
52+
---
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "ms-compitem-crud.name" . }}
5+
spec:
6+
selector:
7+
app: {{ include "ms-compitem-crud.name" . }}
8+
ports:
9+
- protocol: TCP
10+
port: 80
11+
targetPort: 80
12+
type: NodePort
13+
---

chart/ms-validate-user/values.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
nameOverride: ""
2+
fullnameOverride: ""
3+
4+
replicaCount: 1
5+
6+
image:
7+
# TODO - update image params when image is pushed to repo.
8+
repository: quay.io/ortelius/ms-compitem-crud
9+
#digest:
10+
tag: main-v9.0.0.17-g106d15a
11+
12+
service:
13+
type: NodePort
14+
portName: env2app-port
15+
exposedPort: 8080
16+
targetPort: 80
17+
nodePort: 30080
18+
19+
envVars:
20+
DB_HOST: 192.168.10.96
21+
DB_PORT: 6543
22+
DB_NAME: postgres
23+
24+
25+
resources: {}
26+
# limits:
27+
# cpu: 100m
28+
# memory: 128Mi
29+
# requests:
30+
# cpu: 100m
31+
# memory: 128Mi

cloudbuild/cloudbuild.yaml

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,73 @@
11
steps:
22
# Get ssh key from Google Secret Manager
33
- name: gcr.io/cloud-builders/gcloud
4-
id: sshkey
4+
id: ssh_keys
55
entrypoint: 'bash'
6-
args: [ '-c', 'gcloud secrets versions access latest --secret=ortelius-github > /root/.ssh/id_rsa;chmod 600 /root/.ssh/id_rsa;ssh-keyscan -t rsa github.com > /root/.ssh/known_hosts' ]
6+
args: [ '-c', 'gcloud secrets versions access latest --secret=github > /root/.ssh/id_rsa;chmod 600 /root/.ssh/id_rsa;ssh-keyscan -t rsa github.com > /root/.ssh/known_hosts' ]
77
volumes:
88
- name: 'ssh'
99
path: /root/.ssh
10+
11+
# Login to Quay for push.
12+
- name: 'gcr.io/cloud-builders/docker'
13+
id: login
14+
waitFor: ['ssh_keys']
15+
entrypoint: 'bash'
16+
args: ['-c', 'docker login quay.io --username "$$QUAY_USERID" --password $$QUAY_PASSWORD']
17+
secretEnv: ['QUAY_USERID', 'QUAY_PASSWORD']
18+
env:
19+
- 'DOCKER_CONFIG=/workspace/docker-config'
1020

21+
# Setup environment including img tag name for nginx
1122
- name: gcr.io/cloud-builders/docker
12-
id: cloudbuild_sh
23+
id: env
24+
waitFor: ['login']
1325
entrypoint: 'bash'
14-
args: ['-c', 'ls -A1 | xargs rm -rf;git clone $$COMPONENT_GITURL .;git checkout --track -b $BRANCH_NAME origin/$BRANCH_NAME;env | sed "s/^/export /" >> /workspace/cloudbuild.sh']
26+
args: ['-c', 'ls -A1 | grep -v docker-config | xargs rm -rf;git init; git remote add origin $$COMPONENT_GITURL;git fetch;git checkout --track -b $BRANCH_NAME origin/$BRANCH_NAME;env | sed "s/^/export /" >> /workspace/cloudbuild.sh']
1527
volumes:
1628
- name: 'ssh'
1729
path: /root/.ssh
1830
env:
31+
- 'COMPONENT_APPLICATION=GLOBAL.ortelius.saas.ortelius-devops'
32+
- 'COMPONENT_NAME=GLOBAL.ortelius.saas.ms-compitem-crud'
1933
- 'COMPONENT_GITURL=git@github.com:ortelius/ortelius-ms-compitem-crud.git'
20-
- 'COMPONENT_VERSION=9.0.0'
34+
- 'COMPONENT_VARIANT=$BRANCH_NAME'
35+
- 'COMPONENT_VERSION=10.0.0'
36+
- 'COMPONENT_VERSION_COMMIT="v$$COMPONENT_VERSION.$$(git rev-list --count $BRANCH_NAME)-g$SHORT_SHA"'
2137
- 'COMPONENT_DOCKERREPO=quay.io/ortelius/ms-compitem-crud'
38+
- 'COMPONENT_CUSTOMACTION=GLOBAL.HelmChart'
39+
- 'COMPONENT_CHARTNAME=chart/ms-compitem-crud'
40+
- 'COMPONENT_CHARTNAMESPACE=ortelius'
41+
- 'DEPLOY_ENV=GLOBAL.ortelius.saas.aks-cluster'
2242
- 'BLDDATE=`date`'
2343
- 'IMAGE_TAG="$BRANCH_NAME-v$$COMPONENT_VERSION.$$(git rev-list --count $BRANCH_NAME)-g$SHORT_SHA"'
44+
- 'DOCKER_CONFIG=/workspace/docker-config'
2445

25-
# Login to Quay for push.
46+
# Build and push quay.io/ortelius/ms-compitem-crud
2647
- name: 'gcr.io/cloud-builders/docker'
27-
id: login
48+
id: build_push
49+
waitFor: ['env']
2850
entrypoint: 'bash'
29-
args: ['-c', '. /workspace/cloudbuild.sh;docker login quay.io --username "$$QUAY_USERID" --password $$QUAY_PASSWORD']
30-
secretEnv: ['QUAY_USERID', 'QUAY_PASSWORD']
51+
args: ["-c", '. /workspace/cloudbuild.sh;docker build --tag $$COMPONENT_DOCKERREPO:$$IMAGE_TAG -f /workspace/Dockerfile .;docker push $$COMPONENT_DOCKERREPO:$$IMAGE_TAG']
3152
env:
3253
- 'DOCKER_CONFIG=/workspace/docker-config'
3354

34-
# Build and push deployhub-webadmin.war - quay.io/ortelius/ms-textfile-crud
55+
# Get image id
3556
- name: 'gcr.io/cloud-builders/docker'
36-
id: ortelius
37-
waitFor: [ 'login' ]
57+
id: digest
58+
waitFor: ['build_push']
3859
entrypoint: 'bash'
39-
args: ["-c", '. /workspace/cloudbuild.sh;docker build --tag $$COMPONENT_DOCKERREPO:$$IMAGE_TAG -f /workspace/Dockerfile .;docker push $$COMPONENT_DOCKERREPO:$$IMAGE_TAG']
4060
env:
4161
- 'DOCKER_CONFIG=/workspace/docker-config'
62+
args: ['-c', ". /workspace/cloudbuild.sh;echo export DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' $$COMPONENT_DOCKERREPO:$$IMAGE_TAG) >> /workspace/cloudbuild.sh" ]
63+
64+
# Capture new component version in DeployHub
65+
- name: 'quay.io/deployhub/compupdate'
66+
id: compupdate
67+
waitFor: ['digest']
68+
entrypoint: 'bash'
69+
secretEnv: ['DHUSER', 'DHPASS']
70+
args: ['-c', '. /workspace/cloudbuild.sh;dh updatecomp --dhurl https://console.deployhub.com --appname "$$COMPONENT_APPLICATION" --compname "$$COMPONENT_NAME" --compvariant "$$COMPONENT_VARIANT" --compversion "$$COMPONENT_VERSION_COMMIT" --deployenv "$$DEPLOY_ENV" --docker --compattr "GitCommit:$SHORT_SHA" --compattr "GitUrl:$$COMPONENT_GITURL" --compattr "GitRepo:ortelius/$REPO_NAME" --compattr "GitTag:$TAG_NAME" --compattr "GitBranch:$BRANCH_NAME" --compattr "Chart:$$COMPONENT_CHARTNAME" --compattr "DockerSha:$$DIGEST" --compattr "DockerBuildDate:$$BLDDATE" --compattr "DockerRepo:$$COMPONENT_DOCKERREPO" --compattr "BuildId:$BUILD_ID" --compattr "BuildUrl:https://console.cloud.google.com/cloud-build/builds/$BUILD_ID?project=$PROJECT_ID" --compattr "CustomAction:$$COMPONENT_CUSTOMACTION" --compattr "DockerTag:$$IMAGE_TAG" --compattr "ChartNamespace:$$COMPONENT_CHARTNAMESPACE"']
4271

4372
secrets:
4473
- kmsKeyName: projects/eighth-physics-169321/locations/global/keyRings/cli/cryptoKeys/quay
@@ -47,4 +76,9 @@ secrets:
4776
- kmsKeyName: projects/eighth-physics-169321/locations/global/keyRings/cli/cryptoKeys/quay-pw
4877
secretEnv:
4978
QUAY_PASSWORD: CiQAUULEud9Ej8XtwNAb9gkbDVhSGFZYhUGE30fNwR+7ehAOkH8SMgCz6KYeykjgS16RPxgKlrIQL/1TKDt06v4OXGIisFXOkdWC+jvdda8mTzVNCi8sT5g6
50-
79+
- kmsKeyName: projects/eighth-physics-169321/locations/global/keyRings/cli/cryptoKeys/ortelius-id
80+
secretEnv:
81+
DHUSER: CiQAGgJuQMHWANazqTOeE/SyoX/YNVWnES7eJEVWY8mTP98Er3USMQC43iiopoGYhP/YahsQu/yUURiqJBVZURYiUiu5Z7UBkrDgUAonKCKjtzeSNUP7HoQ=
82+
- kmsKeyName: projects/eighth-physics-169321/locations/global/keyRings/cli/cryptoKeys/ortelius-pw
83+
secretEnv:
84+
DHPASS: CiQAZySXz07McN9e6fyr6X4qwkw4iBgeULmpq16RbxIAcqg6gTESMQB98+y30zqMVPx2S/Q/8ld+qlJWWxmocnbjLe9iyepMwyMl3yf+r5e55nf85PlrBBw=

0 commit comments

Comments
 (0)