Add deployment and fix lots of bugs
This commit is contained in:
parent
f5cc32b78f
commit
dbbbfa87bf
|
@ -1,22 +0,0 @@
|
||||||
1. Get the application URL by running these commands:
|
|
||||||
{{- if .Values.ingress.enabled }}
|
|
||||||
{{- range $host := .Values.ingress.hosts }}
|
|
||||||
{{- range .paths }}
|
|
||||||
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
|
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
|
||||||
{{- else if contains "NodePort" .Values.service.type }}
|
|
||||||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "exam.fullname" . }})
|
|
||||||
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
|
||||||
echo http://$NODE_IP:$NODE_PORT
|
|
||||||
{{- else if contains "LoadBalancer" .Values.service.type }}
|
|
||||||
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
|
|
||||||
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "exam.fullname" . }}'
|
|
||||||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "exam.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
|
|
||||||
echo http://$SERVICE_IP:{{ .Values.service.port }}
|
|
||||||
{{- else if contains "ClusterIP" .Values.service.type }}
|
|
||||||
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "exam.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
|
|
||||||
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
|
|
||||||
echo "Visit http://127.0.0.1:8080 to use your application"
|
|
||||||
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
|
|
||||||
{{- end }}
|
|
|
@ -1,59 +1,64 @@
|
||||||
|
{{- range $deploy := .Values.deployments }}
|
||||||
|
---
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ include "exam.fullname" . }}
|
name: {{ include "exam.fullname" $ }}-{{ $deploy.name }}
|
||||||
labels:
|
labels:
|
||||||
{{- include "exam.labels" . | nindent 4 }}
|
app: {{ $deploy.name }}
|
||||||
|
{{- include "exam.labels" $ | nindent 4 }}
|
||||||
spec:
|
spec:
|
||||||
replicas: {{ .Values.replicaCount }}
|
replicas: {{ .replicas }}
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
{{- include "exam.selectorLabels" . | nindent 6 }}
|
app: {{ $deploy.name }}
|
||||||
|
tier: {{ $deploy.tier }}
|
||||||
|
{{- include "exam.selectorLabels" $ | nindent 6 }}
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
{{- with .Values.podAnnotations }}
|
|
||||||
annotations:
|
|
||||||
{{- toYaml . | nindent 8 }}
|
|
||||||
{{- end }}
|
|
||||||
labels:
|
labels:
|
||||||
{{- include "exam.selectorLabels" . | nindent 8 }}
|
app: {{ $deploy.name }}
|
||||||
|
tier: {{ $deploy.tier }}
|
||||||
|
{{- include "exam.selectorLabels" $ | nindent 8 }}
|
||||||
spec:
|
spec:
|
||||||
{{- with .Values.imagePullSecrets }}
|
|
||||||
imagePullSecrets:
|
|
||||||
{{- toYaml . | nindent 8 }}
|
|
||||||
{{- end }}
|
|
||||||
serviceAccountName: {{ include "exam.serviceAccountName" . }}
|
|
||||||
securityContext:
|
|
||||||
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
|
||||||
containers:
|
containers:
|
||||||
- name: {{ .Chart.Name }}
|
- name: {{ $deploy.name }}
|
||||||
securityContext:
|
{{- with $deploy.image }}
|
||||||
{{- toYaml .Values.securityContext | nindent 12 }}
|
image: {{ .repository }}:{{ .tag | default $.Chart.AppVersion }}
|
||||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
|
{{- end }}
|
||||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
|
||||||
ports:
|
ports:
|
||||||
- name: http
|
- name: {{ $deploy.name }}
|
||||||
containerPort: {{ .Values.service.port }}
|
containerPort: {{ $deploy.port }}
|
||||||
protocol: TCP
|
{{- if $deploy.env }}
|
||||||
livenessProbe:
|
env:
|
||||||
httpGet:
|
{{- with $deploy.env }}
|
||||||
path: /
|
{{- range $key, $val := .nonsecrets }}
|
||||||
port: http
|
{{- $envKey := $key | upper | replace "-" "_" }}
|
||||||
readinessProbe:
|
- name: {{ $envKey }}
|
||||||
httpGet:
|
value: {{ quote $val }}
|
||||||
path: /
|
|
||||||
port: http
|
|
||||||
resources:
|
|
||||||
{{- toYaml .Values.resources | nindent 12 }}
|
|
||||||
{{- with .Values.nodeSelector }}
|
|
||||||
nodeSelector:
|
|
||||||
{{- toYaml . | nindent 8 }}
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- with .Values.affinity }}
|
{{- range $key, $val := .secrets }}
|
||||||
affinity:
|
{{- $envKey := $key | upper | replace "-" "_" }}
|
||||||
{{- toYaml . | nindent 8 }}
|
- name: {{ $envKey }}
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
# TODO
|
||||||
|
name: {{ include "exam.fullname" $ }}-secrets
|
||||||
|
key: {{ $val }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
resources: {}
|
||||||
|
{{- if $deploy.mountPath }}
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: {{ .mountPath }}
|
||||||
|
name: {{ .storage }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $deploy.mountPath }}
|
||||||
|
volumes:
|
||||||
|
- name: {{ .storage }}
|
||||||
|
persistentVolumeClaim:
|
||||||
|
# TODO
|
||||||
|
claimName: {{ include "exam.fullname" $ }}-postgres-pv-claim
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- with .Values.tolerations }}
|
|
||||||
tolerations:
|
|
||||||
{{- toYaml . | nindent 8 }}
|
|
||||||
{{- end }}
|
{{- end }}
|
|
@ -1,7 +1,7 @@
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ include "exam.fullname" . }}-postgres-secrets
|
name: {{ include "exam.fullname" . }}-secrets
|
||||||
labels:
|
labels:
|
||||||
{{- include "exam.labels" . | nindent 4 }}
|
{{- include "exam.labels" . | nindent 4 }}
|
||||||
data:
|
data:
|
||||||
|
|
|
@ -11,5 +11,5 @@ spec:
|
||||||
- name: wget
|
- name: wget
|
||||||
image: busybox
|
image: busybox
|
||||||
command: ['wget']
|
command: ['wget']
|
||||||
args: ['{{ include "exam.fullname" . }}:{{ .Values.service.port }}']
|
args: ['{{ include "exam.fullname" . }}:5000']
|
||||||
restartPolicy: Never
|
restartPolicy: Never
|
||||||
|
|
|
@ -1,31 +1,10 @@
|
||||||
replicaCount: 1
|
replicaCount: 1
|
||||||
|
|
||||||
image:
|
|
||||||
repository: nginx
|
|
||||||
pullPolicy: IfNotPresent
|
|
||||||
tag: ""
|
|
||||||
|
|
||||||
imagePullSecrets: []
|
|
||||||
|
|
||||||
serviceAccount:
|
serviceAccount:
|
||||||
# Specifies whether a service account should be created
|
|
||||||
create: false
|
create: false
|
||||||
# Annotations to add to the service account
|
|
||||||
annotations: {}
|
annotations: {}
|
||||||
# The name of the service account to use.
|
|
||||||
# If not set and create is true, a name is generated using the fullname template
|
|
||||||
name: ""
|
name: ""
|
||||||
|
|
||||||
podAnnotations: {}
|
|
||||||
|
|
||||||
podSecurityContext: {}
|
|
||||||
|
|
||||||
securityContext: {}
|
|
||||||
|
|
||||||
service:
|
|
||||||
type: ClusterIP
|
|
||||||
port: 80
|
|
||||||
|
|
||||||
ingress:
|
ingress:
|
||||||
ssl: false
|
ssl: false
|
||||||
className: ""
|
className: ""
|
||||||
|
@ -57,26 +36,72 @@ tolerations: []
|
||||||
|
|
||||||
affinity: {}
|
affinity: {}
|
||||||
|
|
||||||
|
# TODO: merge with deployments
|
||||||
services:
|
services:
|
||||||
- api:
|
- api:
|
||||||
name: "api"
|
name: "api"
|
||||||
tier: "backend"
|
tier: "backend"
|
||||||
port: 5000
|
port: 5000
|
||||||
target: 0
|
target: 0
|
||||||
|
type: ClusterIP
|
||||||
- postgres:
|
- postgres:
|
||||||
name: "postgres"
|
name: "db"
|
||||||
tier: "backend"
|
tier: "backend"
|
||||||
port: 5432
|
port: 5432
|
||||||
target: 0
|
target: 0
|
||||||
|
type: ClusterIP
|
||||||
- client:
|
- client:
|
||||||
name: "client"
|
name: "client"
|
||||||
tier: "frontend"
|
tier: "frontend"
|
||||||
port: 8080
|
port: 8080
|
||||||
target: 80
|
target: 80
|
||||||
|
type: ClusterIP
|
||||||
|
|
||||||
secrets:
|
secrets:
|
||||||
password: "username"
|
password: "username"
|
||||||
username: "password1234"
|
username: "password1234"
|
||||||
|
|
||||||
pvc:
|
pvc:
|
||||||
storageClass: manual
|
class: manual
|
||||||
storageRequest: 1Gi
|
request: 1Gi
|
||||||
|
|
||||||
|
deployments:
|
||||||
|
- api:
|
||||||
|
name: "api"
|
||||||
|
tier: "backend"
|
||||||
|
env:
|
||||||
|
nonsecrets:
|
||||||
|
app-settings: src.config.ProductionConfig
|
||||||
|
database-url: postgresql://$(POSTGRES_USER):$(POSTGRES_PASS)@api-db/$(POSTGRES_DB)
|
||||||
|
port: "5000"
|
||||||
|
postgres-db: api-db
|
||||||
|
secrets:
|
||||||
|
postgres-password: password
|
||||||
|
postgres-user: username
|
||||||
|
image:
|
||||||
|
repository: api
|
||||||
|
tag: prod
|
||||||
|
port: 5000
|
||||||
|
replicas: 3
|
||||||
|
- client:
|
||||||
|
tier: "frontend"
|
||||||
|
name: "client"
|
||||||
|
image:
|
||||||
|
repository: client
|
||||||
|
tag: prod
|
||||||
|
port: 8080
|
||||||
|
replicas: 1
|
||||||
|
- db:
|
||||||
|
tier: "backend"
|
||||||
|
name: "db"
|
||||||
|
env:
|
||||||
|
nonsecrets:
|
||||||
|
pgdata: /var/lib/postgresql/data/pgdata
|
||||||
|
postgresDb: db
|
||||||
|
image:
|
||||||
|
repository: db
|
||||||
|
tag: 13.3
|
||||||
|
port: 5432
|
||||||
|
replicas: 1
|
||||||
|
mountPath: /var/lib/postgresql/data
|
||||||
|
storage: postgres-pv-storage
|
||||||
|
|
Loading…
Reference in New Issue