Skip to content

Commit 5108f72

Browse files
committed
wip
1 parent 07034a3 commit 5108f72

24 files changed

+577
-94
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# helm-charts/**/*

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"parser": "yaml",
3+
"bracketSpacing": false
4+
}

.vscode/tasks.json

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,46 @@
11
{
2-
"version": "2.0.0",
3-
"tasks": [
4-
{
5-
"type": "npm",
6-
"script": "build:docker",
7-
"group": "build",
8-
"isBackground": true,
9-
"presentation": {
10-
"echo": true,
11-
"reveal": "silent",
12-
"focus": false,
13-
"panel": "shared",
14-
"showReuseMessage": true,
15-
"clear": false
16-
},
17-
"problemMatcher": [],
18-
"label": "npm: build:docker",
19-
"detail": "docker build --tag cjlapao/deployment-tools:latest .",
20-
},
21-
{
22-
"type": "npm",
23-
"script": "publish:docker",
24-
"group": "build",
25-
"isBackground": true,
26-
"presentation": {
27-
"echo": true,
28-
"reveal": "silent",
29-
"focus": false,
30-
"panel": "shared",
31-
"showReuseMessage": true,
32-
"clear": false
33-
},
34-
"problemMatcher": [],
35-
"label": "npm: publish:docker",
36-
"detail": "docker push cjlapao/deployment-tools:latest",
37-
"dependsOn": ["npm: build:docker"]
38-
}
39-
]
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "shell",
6+
"group": "build",
7+
"isBackground": true,
8+
"presentation": {
9+
"echo": true,
10+
"reveal": "silent",
11+
"focus": false,
12+
"panel": "shared",
13+
"showReuseMessage": true,
14+
"clear": false
15+
},
16+
"command": "docker build --tag cjlapao/go-restapi-demo:latest .",
17+
"windows": {
18+
"command": "docker build --tag cjlapao/go-restapi-demo:latest .",
19+
},
20+
"problemMatcher": [],
21+
"label": "build:docker"
22+
},
23+
{
24+
"type": "shell",
25+
"group": "build",
26+
"isBackground": true,
27+
"presentation": {
28+
"echo": true,
29+
"reveal": "silent",
30+
"focus": false,
31+
"panel": "shared",
32+
"showReuseMessage": true,
33+
"clear": false
34+
},
35+
"problemMatcher": [],
36+
"command": "docker push cjlapao/go-restapi-demo:latest",
37+
"windows": {
38+
"command": "docker push cjlapao/go-restapi-demo:latest",
39+
},
40+
"label": "publish:docker",
41+
"dependsOn": [
42+
"build:docker"
43+
]
44+
}
45+
]
4046
}

executioncontext/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ func (e *Context) Getenv() {
4242
e.Database = os.Getenv("RESTAPI_DATABASENAME")
4343
e.MongoConnectionString = os.Getenv("RESTAPI_MONGO_CONNECTION_STRING")
4444
e.ApiPrefix = os.Getenv("RESTAPI_API_PREFIX")
45-
e.ApiPort = os.Getenv("
46-
")
45+
e.ApiPort = os.Getenv("RESTAPI_API_PORT")
4746

4847
if e.MongoConnectionString == "" {
4948
e.BackendEnabled = false

helm-charts/restapi-testapp/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apiVersion: v2
2-
name: restapi-testapp
2+
name: restapi-demo
33
description: A Helm chart for Kubernetes
44

55
# A chart can be either an 'application' or a 'library' chart.

helm-charts/restapi-testapp/templates/NOTES.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
1. Get the application URL by running these commands:
2-
{{- if .Values.ingress.enabled }}
2+
{{- if .Values.ingress.virtualService.enabled }}
33
{{- range $host := .Values.ingress.hosts }}
44
{{- range .paths }}
55
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
66
{{- end }}
77
{{- end }}
8-
{{- else if contains "NodePort" .Values.service.type }}
8+
{% comment %} {{- else if contains "NodePort" .Values.service.type }}
99
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "restapi-testapp.fullname" . }})
1010
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
1111
echo http://$NODE_IP:$NODE_PORT
@@ -19,4 +19,4 @@
1919
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
2020
echo "Visit http://127.0.0.1:8080 to use your application"
2121
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
22-
{{- end }}
22+
{{- end }} {% endcomment %}

helm-charts/restapi-testapp/templates/_helpers.tpl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
{{/*
2-
Expand the name of the chart.
3-
*/}}
41
{{- define "restapi-testapp.name" -}}
52
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
63
{{- end }}
@@ -40,6 +37,7 @@ helm.sh/chart: {{ include "restapi-testapp.chart" . }}
4037
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
4138
{{- end }}
4239
app.kubernetes.io/managed-by: {{ .Release.Service }}
40+
app.kubernetes.io/component: api-demo
4341
{{- end }}
4442

4543
{{/*
@@ -48,6 +46,7 @@ Selector labels
4846
{{- define "restapi-testapp.selectorLabels" -}}
4947
app.kubernetes.io/name: {{ include "restapi-testapp.name" . }}
5048
app.kubernetes.io/instance: {{ .Release.Name }}
49+
app.kubernetes.io/environment: development
5150
{{- end }}
5251

5352
{{/*
Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
4-
namespace: playground
5-
labels:
6-
app: go-api-demo
7-
environment: development
8-
name: go-api-demo
4+
namespace: {{ .Values.namespace.name }}
5+
labels:
6+
{{- include "restapi-testapp.labels" . | nindent 4 }}
7+
name: {{ include "restapi-testapp.fullname" .}}
98
spec:
10-
replicas: 1
11-
selector:
12-
matchLabels:
13-
app: go-api-demo
14-
environment: development
15-
template:
16-
metadata:
17-
labels:
18-
app: go-api-demo
19-
environment: development
20-
spec:
21-
containers:
22-
- image: cjlapao/go-restapi-demo:latest
23-
imagePullPolicy: Always
24-
name: go-api-demo
25-
resources:
26-
requests: { cpu: '150m', memory: '25Mi' }
27-
limits: { cpu: '250m', memory: '50Mi' }
28-
env:
29-
- name: RESTAPI_API_PORT
30-
value: { { .Values.apiPort } }
31-
dnsPolicy: ClusterFirstWithHostNet
32-
restartPolicy: Always
9+
{{- if not .Values.autoscaling.enabled }}
10+
replicas: {{ .Values.replicaCount }}
11+
{{- end }}
12+
selector:
13+
matchLabels:
14+
{{- include "restapi-testapp.selectorLabels" . | nindent 6 }}
15+
template:
16+
metadata:
17+
labels:
18+
{{- include "restapi-testapp.selectorLabels" . | nindent 8 }}
19+
spec:
20+
containers:
21+
- image: cjlapao/go-restapi-demo:latest
22+
imagePullPolicy: Always
23+
name: go-api-demo
24+
resources:
25+
requests: {cpu: "150m", memory: "25Mi"}
26+
limits: {cpu: "250m", memory: "50Mi"}
27+
env:
28+
- name: RESTAPI_API_PORT
29+
value: {{ .Values.apiPort | quote }}
30+
dnsPolicy: ClusterFirstWithHostNet
31+
restartPolicy: Always
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{- if .Values.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2beta1
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "restapi-testapp.fullname" . }}
6+
namespace:
7+
labels:
8+
{{- include "restapi-testapp.labels" . | nindent 4 }}
9+
spec:
10+
scaleTargetRef:
11+
apiVersion: apps/v1
12+
kind: Deployment
13+
name: {{ include "restapi-testapp.fullname" . }}
14+
minReplicas: {{ .Values.autoscaling.minReplicas }}
15+
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
16+
metrics:
17+
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
18+
- type: Resource
19+
resource:
20+
name: cpu
21+
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
22+
{{- end }}
23+
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
24+
- type: Resource
25+
resource:
26+
name: memory
27+
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
28+
{{- end }}
29+
{{- end }}
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
s
1+
{{ if .Values.namespace.create }}
2+
apiVersion: v1
3+
kind: Namespace
4+
metadata:
5+
name: {{.Values.namespace.name}}
6+
{{end}}
Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
apiVersion: v1
22
kind: Service
33
metadata:
4-
name: go-api-demo
5-
namespace: playground
6-
labels:
7-
app: go-api-demo
8-
environment: development
9-
annotations:
10-
service.alpha.kubernetes.io/tolerate-unready-endpoints: 'true'
4+
namespace: {{.Values.namespace.name}}
5+
name: {{include "restapi-testapp.fullname" .}}
6+
labels: {{- include "restapi-testapp.labels" . | nindent 4}}
7+
annotations:
8+
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
119
spec:
12-
type: ClusterIP
13-
ports:
14-
- protocol: TCP
15-
name: api
16-
port: 80
17-
targetPort: { { .Values.apiPort } }
18-
selector:
19-
app: go-api-demo
20-
environment: development
21-
sessionAffinity: None
10+
type: {{.Values.service.type}}
11+
ports:
12+
- protocol: TCP
13+
name: api
14+
port: {{.Values.service.port}}
15+
targetPort: {{.Values.apiPort}}
16+
selector: {{- include "restapi-testapp.selectorLabels" . | nindent 4}}
17+
sessionAffinity: None
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{ $namespace := .Values.namespace.name }}
2+
{{ $fullname := include "restapi-testapp.fullname" .}}
3+
{{ if .Values.ingress.virtualService.enabled }}
4+
apiVersion: networking.istio.io/v1beta1
5+
kind: VirtualService
6+
metadata:
7+
name: {{ include "restapi-testapp.fullname" .}}
8+
labels: {{ include "restapi-testapp.labels" . | nindent 4}}
9+
spec:
10+
hosts:
11+
- {{ .Values.ingress.host }}
12+
http:
13+
{{ range $value := .Values.ingress.paths}}
14+
- name: {{ .name }}
15+
match:
16+
- uri:
17+
prefix: {{ .route }}
18+
route:
19+
- destination:
20+
host: {{$fullname}}.{{$namespace}}.svc.cluster.local
21+
{{ end }}
22+
{{ end }}
Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
11
apiPort: 10000
2+
replicaCount: 1
3+
service:
4+
port: 80
5+
namespace:
6+
name: demo
7+
create: true
28
serviceAccount:
3-
create: false
9+
create: true
10+
autoscaling:
11+
enabled: true
12+
minReplicas: 2
13+
maxReplicas: 5
14+
targetCPUUtilizationPercentage: 30
15+
targetMemoryUtilizationPercentage: 75
16+
ingress:
17+
tls: true
18+
host: 'test.local-cluster.internal'
19+
paths:
20+
- name: "hello"
21+
route: "/hello"
22+
virtualService:
23+
enabled: true

tester/.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/

tester/Chart.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: tester
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "1.16.0"

0 commit comments

Comments
 (0)