This commit is contained in:
2024-02-20 17:15:27 +08:00
committed by huty
parent 6706e1a633
commit 34158042ad
1529 changed files with 177765 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

View File

@@ -0,0 +1,6 @@
apiVersion: v2
name: todo-list
description: Kiamol Ch12 app
type: application
version: 0.1.0
appVersion: 1.0.0

View File

@@ -0,0 +1,2 @@
Installed Kiamol to-do list {{ .Chart.Version }}. This is how to get the URL:
$ kubectl get svc {{ .Release.Name }}-web -o jsonpath='http://{.status.loadBalancer.ingress[0].*}:{{ .Values.servicePort }}'

View File

@@ -0,0 +1,46 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-db
labels:
kiamol: ch12
spec:
selector:
matchLabels:
app: {{ .Release.Name }}-db
template:
metadata:
labels:
app: {{ .Release.Name }}-db
spec:
containers:
- name: db
image: postgres:11.6-alpine
env:
- name: POSTGRES_PASSWORD_FILE
value: /secrets/postgres_password
volumeMounts:
- name: secret
mountPath: "/secrets"
- name: data
mountPath: /var/lib/postgresql/data
readinessProbe:
tcpSocket:
port: 5432
periodSeconds: 5
livenessProbe:
exec:
command: ["pg_isready", "-h", "localhost"]
periodSeconds: 10
initialDelaySeconds: 10
volumes:
- name: secret
secret:
secretName: {{ .Release.Name }}-db-secret
defaultMode: 0400
items:
- key: POSTGRES_PASSWORD
path: postgres_password
- name: data
persistentVolumeClaim:
claimName: {{ .Release.Name }}-db-pvc

View File

@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Release.Name }}-db-pvc
labels:
kiamol: ch12
annotations:
"helm.sh/hook": pre-install
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Mi

View File

@@ -0,0 +1,11 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-db-secret
labels:
kiamol: ch12
annotations:
"helm.sh/hook": pre-install
type: Opaque
stringData:
POSTGRES_PASSWORD: "kiamol-2*2*"

View File

@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-db
labels:
kiamol: ch12
spec:
ports:
- port: 5432
targetPort: 5432
selector:
app: {{ .Release.Name }}-db

View File

@@ -0,0 +1,18 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-web-config
labels:
kiamol: ch12
annotations:
"helm.sh/hook": pre-install
data:
config.json: |-
{
"ConfigController": {
"Enabled" : true
},
"Database" : {
"Provider" : "Postgres"
}
}

View File

@@ -0,0 +1,51 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-web
labels:
kiamol: ch12
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ .Release.Name }}-web
template:
metadata:
labels:
app: {{ .Release.Name }}-web
spec:
containers:
- name: web
image: kiamol/ch04-todo-list
volumeMounts:
- name: config
mountPath: "/app/config"
readOnly: true
- name: secret
mountPath: "/app/secrets"
readOnly: true
readinessProbe:
httpGet:
path: /
port: 80
periodSeconds: 5
livenessProbe:
httpGet:
path: /
port: 80
periodSeconds: 10
initialDelaySeconds: 10
volumes:
- name: config
configMap:
name: {{ .Release.Name }}-web-config
items:
- key: config.json
path: config.json
- name: secret
secret:
secretName: {{ .Release.Name }}-web-secret
defaultMode: 0400
items:
- key: secrets.json
path: secrets.json

View File

@@ -0,0 +1,16 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-web-secret
labels:
kiamol: ch12
annotations:
"helm.sh/hook": pre-install
type: Opaque
stringData:
secrets.json: |-
{
"ConnectionStrings": {
"ToDoDb": "Server={{ .Release.Name }}-db;Database=todo;User Id=postgres;Password=kiamol-2*2*;"
}
}

View File

@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-web
labels:
kiamol: ch12
spec:
ports:
- port: {{ .Values.servicePort }}
targetPort: 80
selector:
app: {{ .Release.Name }}-web
type: {{ .Values.serviceType }}

View File

@@ -0,0 +1,6 @@
# number of replicas for the web Deployment:
replicaCount: 2
# port for the Service to listen on:
servicePort: 8012
# type of the Service:
serviceType: LoadBalancer

View File

@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

View File

@@ -0,0 +1,6 @@
apiVersion: v2
name: todo-list
description: Kiamol Ch12 app
type: application
version: 0.2.0
appVersion: 1.0.0

View File

@@ -0,0 +1,2 @@
Installed Kiamol to-do list {{ .Chart.Version }}. This is how to get the URL:
$ kubectl get svc {{ .Release.Name }}-web -o jsonpath='http://{.status.loadBalancer.ingress[0].*}:{{ .Values.servicePort }}'

View File

@@ -0,0 +1,47 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-db
labels:
kiamol: ch12
spec:
selector:
matchLabels:
app: {{ .Release.Name }}-db
template:
metadata:
labels:
app: {{ .Release.Name }}-db
spec:
containers:
- name: db
image: postgres:11.8-alpine
command: ["sh", "-c", "sleep 30m"]
env:
- name: POSTGRES_PASSWORD_FILE
value: /secrets/postgres_password
volumeMounts:
- name: secret
mountPath: "/secrets"
- name: data
mountPath: /var/lib/postgresql/data
readinessProbe:
tcpSocket:
port: 5432
periodSeconds: 5
livenessProbe:
exec:
command: ["pg_isready", "-h", "localhost"]
periodSeconds: 10
initialDelaySeconds: 10
volumes:
- name: secret
secret:
secretName: {{ .Release.Name }}-db-secret
defaultMode: 0400
items:
- key: POSTGRES_PASSWORD
path: postgres_password
- name: data
persistentVolumeClaim:
claimName: {{ .Release.Name }}-db-pvc

View File

@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Release.Name }}-db-pvc
labels:
kiamol: ch12
annotations:
"helm.sh/hook": pre-install
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Mi

View File

@@ -0,0 +1,11 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-db-secret
labels:
kiamol: ch12
annotations:
"helm.sh/hook": pre-install
type: Opaque
stringData:
POSTGRES_PASSWORD: "kiamol-2*2*"

View File

@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-db
labels:
kiamol: ch12
spec:
ports:
- port: 5432
targetPort: 5432
selector:
app: {{ .Release.Name }}-db

View File

@@ -0,0 +1,18 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-web-config
labels:
kiamol: ch12
annotations:
"helm.sh/hook": pre-install
data:
config.json: |-
{
"ConfigController": {
"Enabled" : true
},
"Database" : {
"Provider" : "Postgres"
}
}

View File

@@ -0,0 +1,51 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-web
labels:
kiamol: ch12
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ .Release.Name }}-web
template:
metadata:
labels:
app: {{ .Release.Name }}-web
spec:
containers:
- name: web
image: kiamol/ch04-todo-list
volumeMounts:
- name: config
mountPath: "/app/config"
readOnly: true
- name: secret
mountPath: "/app/secrets"
readOnly: true
readinessProbe:
httpGet:
path: /
port: 80
periodSeconds: 5
livenessProbe:
httpGet:
path: /
port: 80
periodSeconds: 10
initialDelaySeconds: 10
volumes:
- name: config
configMap:
name: {{ .Release.Name }}-web-config
items:
- key: config.json
path: config.json
- name: secret
secret:
secretName: {{ .Release.Name }}-web-secret
defaultMode: 0400
items:
- key: secrets.json
path: secrets.json

View File

@@ -0,0 +1,16 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-web-secret
labels:
kiamol: ch12
annotations:
"helm.sh/hook": pre-install
type: Opaque
stringData:
secrets.json: |-
{
"ConnectionStrings": {
"ToDoDb": "Server={{ .Release.Name }}-db;Database=todo;User Id=postgres;Password=kiamol-2*2*;"
}
}

View File

@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-web
labels:
kiamol: ch12
spec:
ports:
- port: {{ .Values.servicePort }}
targetPort: 80
selector:
app: {{ .Release.Name }}-web
type: {{ .Values.serviceType }}

View File

@@ -0,0 +1,6 @@
# number of replicas for the web Deployment:
replicaCount: 2
# port for the Service to listen on:
servicePort: 8012
# type of the Service:
serviceType: LoadBalancer

View File

@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

View File

@@ -0,0 +1,6 @@
apiVersion: v2
name: todo-list
description: Kiamol Ch12 app
type: application
version: 0.3.0
appVersion: 1.0.0

View File

@@ -0,0 +1,2 @@
Installed Kiamol to-do list {{ .Chart.Version }}. This is how to get the URL:
$ kubectl get svc {{ .Release.Name }}-web -o jsonpath='http://{.status.loadBalancer.ingress[0].*}:{{ .Values.servicePort }}'

View File

@@ -0,0 +1,30 @@
apiVersion: batch/v1
kind: Job
metadata:
name: {{ .Release.Name }}-db-test
labels:
kiamol: ch12
annotations:
"helm.sh/hook": test
spec:
completions: 1
backoffLimit: 0
template:
spec:
restartPolicy: Never
containers:
- name: db
image: postgres:11.8-alpine
env:
- name: PGHOST
value: {{ .Release.Name }}-db
- name: PGDATABASE
value: todo
- name: PGUSER
value: postgres
- name: PGPASSWORD
valueFrom:
secretKeyRef:
key: POSTGRES_PASSWORD
name: todo-db-secret
command: ["psql", "-c", "SELECT COUNT(*) FROM \"public\".\"ToDos\""]

View File

@@ -0,0 +1,46 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-db
labels:
kiamol: ch12
spec:
selector:
matchLabels:
app: {{ .Release.Name }}-db
template:
metadata:
labels:
app: {{ .Release.Name }}-db
spec:
containers:
- name: db
image: postgres:11.8-alpine
env:
- name: POSTGRES_PASSWORD_FILE
value: /secrets/postgres_password
volumeMounts:
- name: secret
mountPath: "/secrets"
- name: data
mountPath: /var/lib/postgresql/data
readinessProbe:
tcpSocket:
port: 5432
periodSeconds: 5
livenessProbe:
exec:
command: ["pg_isready", "-h", "localhost"]
periodSeconds: 10
initialDelaySeconds: 10
volumes:
- name: secret
secret:
secretName: {{ .Release.Name }}-db-secret
defaultMode: 0400
items:
- key: POSTGRES_PASSWORD
path: postgres_password
- name: data
persistentVolumeClaim:
claimName: {{ .Release.Name }}-db-pvc

View File

@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Release.Name }}-db-pvc
labels:
kiamol: ch12
annotations:
"helm.sh/hook": pre-install
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Mi

View File

@@ -0,0 +1,11 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-db-secret
labels:
kiamol: ch12
annotations:
"helm.sh/hook": pre-install
type: Opaque
stringData:
POSTGRES_PASSWORD: "kiamol-2*2*"

View File

@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-db
labels:
kiamol: ch12
spec:
ports:
- port: 5432
targetPort: 5432
selector:
app: {{ .Release.Name }}-db

View File

@@ -0,0 +1,18 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-web-config
labels:
kiamol: ch12
annotations:
"helm.sh/hook": pre-install
data:
config.json: |-
{
"ConfigController": {
"Enabled" : true
},
"Database" : {
"Provider" : "Postgres"
}
}

View File

@@ -0,0 +1,51 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-web
labels:
kiamol: ch12
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ .Release.Name }}-web
template:
metadata:
labels:
app: {{ .Release.Name }}-web
spec:
containers:
- name: web
image: kiamol/ch04-todo-list
volumeMounts:
- name: config
mountPath: "/app/config"
readOnly: true
- name: secret
mountPath: "/app/secrets"
readOnly: true
readinessProbe:
httpGet:
path: /
port: 80
periodSeconds: 5
livenessProbe:
httpGet:
path: /
port: 80
periodSeconds: 10
initialDelaySeconds: 10
volumes:
- name: config
configMap:
name: {{ .Release.Name }}-web-config
items:
- key: config.json
path: config.json
- name: secret
secret:
secretName: {{ .Release.Name }}-web-secret
defaultMode: 0400
items:
- key: secrets.json
path: secrets.json

View File

@@ -0,0 +1,16 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-web-secret
labels:
kiamol: ch12
annotations:
"helm.sh/hook": pre-install
type: Opaque
stringData:
secrets.json: |-
{
"ConnectionStrings": {
"ToDoDb": "Server={{ .Release.Name }}-db;Database=todo;User Id=postgres;Password=kiamol-2*2*;"
}
}

View File

@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-web
labels:
kiamol: ch12
spec:
ports:
- port: {{ .Values.servicePort }}
targetPort: 80
selector:
app: {{ .Release.Name }}-web
type: {{ .Values.serviceType }}

View File

@@ -0,0 +1,6 @@
# number of replicas for the web Deployment:
replicaCount: 2
# port for the Service to listen on:
servicePort: 8012
# type of the Service:
serviceType: LoadBalancer

View File

@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

View File

@@ -0,0 +1,6 @@
apiVersion: v2
name: todo-list
description: Kiamol Ch12 app
type: application
version: 0.4.0
appVersion: 1.0.0

View File

@@ -0,0 +1,2 @@
Installed Kiamol to-do list {{ .Chart.Version }}. This is how to get the URL:
$ kubectl get svc {{ .Release.Name }}-web -o jsonpath='http://{.status.loadBalancer.ingress[0].*}:{{ .Values.servicePort }}'

View File

@@ -0,0 +1,20 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-db-check-scripts
labels:
kiamol: ch12
annotations:
"helm.sh/hook": pre-upgrade
"helm.sh/hook-weight": "1"
data:
check-postgres-version.sh: |-
#!/bin/sh
PG_VERSION=$(pg_config --version)
if [ "$PG_VERSION" == "PostgreSQL 11.6" ]; then
echo '** Postgres at expected version - good to upgrade **'
exit 0
else
echo "** ERROR - Postgres not at expected version - wanted: 11.6, got: $PG_VERSION - CANNOT UPGRADE **"
exit 1
fi

View File

@@ -0,0 +1,39 @@
apiVersion: batch/v1
kind: Job
metadata:
name: {{ .Release.Name }}-db-check
labels:
kiamol: ch12
annotations:
"helm.sh/hook": pre-upgrade
"helm.sh/hook-weight": "10"
spec:
completions: 1
backoffLimit: 0
template:
spec:
restartPolicy: Never
containers:
- name: db
image: postgres:11.8-alpine
env:
- name: PGHOST
value: {{ .Release.Name }}-db
- name: PGDATABASE
value: todo
- name: PGUSER
value: postgres
- name: PGPASSWORD
valueFrom:
secretKeyRef:
key: POSTGRES_PASSWORD
name: todo-db-secret
command: ["/scripts/check-postgres-version.sh"]
volumeMounts:
- name: scripts
mountPath: "/scripts"
volumes:
- name: scripts
configMap:
name: {{ .Release.Name }}-db-check-scripts
defaultMode: 0555

View File

@@ -0,0 +1,30 @@
apiVersion: batch/v1
kind: Job
metadata:
name: {{ .Release.Name }}-db-test
labels:
kiamol: ch12
annotations:
"helm.sh/hook": test
spec:
completions: 1
backoffLimit: 1
template:
spec:
restartPolicy: Never
containers:
- name: db
image: postgres:11.8-alpine
env:
- name: PGHOST
value: {{ .Release.Name }}-db
- name: PGDATABASE
value: todo
- name: PGUSER
value: postgres
- name: PGPASSWORD
valueFrom:
secretKeyRef:
key: POSTGRES_PASSWORD
name: todo-db-secret
command: ["psql", "-c", "SELECT COUNT(*) FROM \"public\".\"ToDos\""]

View File

@@ -0,0 +1,46 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-db
labels:
kiamol: ch12
spec:
selector:
matchLabels:
app: {{ .Release.Name }}-db
template:
metadata:
labels:
app: {{ .Release.Name }}-db
spec:
containers:
- name: db
image: postgres:11.8-alpine
env:
- name: POSTGRES_PASSWORD_FILE
value: /secrets/postgres_password
volumeMounts:
- name: secret
mountPath: "/secrets"
- name: data
mountPath: /var/lib/postgresql/data
readinessProbe:
tcpSocket:
port: 5432
periodSeconds: 5
livenessProbe:
exec:
command: ["pg_isready", "-h", "localhost"]
periodSeconds: 10
initialDelaySeconds: 10
volumes:
- name: secret
secret:
secretName: {{ .Release.Name }}-db-secret
defaultMode: 0400
items:
- key: POSTGRES_PASSWORD
path: postgres_password
- name: data
persistentVolumeClaim:
claimName: {{ .Release.Name }}-db-pvc

View File

@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Release.Name }}-db-pvc
labels:
kiamol: ch12
annotations:
"helm.sh/hook": pre-install
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Mi

View File

@@ -0,0 +1,11 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-db-secret
labels:
kiamol: ch12
annotations:
"helm.sh/hook": pre-install
type: Opaque
stringData:
POSTGRES_PASSWORD: "kiamol-2*2*"

View File

@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-db
labels:
kiamol: ch12
spec:
ports:
- port: 5432
targetPort: 5432
selector:
app: {{ .Release.Name }}-db

View File

@@ -0,0 +1,18 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-web-config
labels:
kiamol: ch12
annotations:
"helm.sh/hook": pre-install
data:
config.json: |-
{
"ConfigController": {
"Enabled" : true
},
"Database" : {
"Provider" : "Postgres"
}
}

View File

@@ -0,0 +1,51 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-web
labels:
kiamol: ch12
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ .Release.Name }}-web
template:
metadata:
labels:
app: {{ .Release.Name }}-web
spec:
containers:
- name: web
image: kiamol/ch04-todo-list
volumeMounts:
- name: config
mountPath: "/app/config"
readOnly: true
- name: secret
mountPath: "/app/secrets"
readOnly: true
readinessProbe:
httpGet:
path: /
port: 80
periodSeconds: 5
livenessProbe:
httpGet:
path: /
port: 80
periodSeconds: 10
initialDelaySeconds: 10
volumes:
- name: config
configMap:
name: {{ .Release.Name }}-web-config
items:
- key: config.json
path: config.json
- name: secret
secret:
secretName: {{ .Release.Name }}-web-secret
defaultMode: 0400
items:
- key: secrets.json
path: secrets.json

View File

@@ -0,0 +1,16 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-web-secret
labels:
kiamol: ch12
annotations:
"helm.sh/hook": pre-install
type: Opaque
stringData:
secrets.json: |-
{
"ConnectionStrings": {
"ToDoDb": "Server={{ .Release.Name }}-db;Database=todo;User Id=postgres;Password=kiamol-2*2*;"
}
}

View File

@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-web
labels:
kiamol: ch12
spec:
ports:
- port: {{ .Values.servicePort }}
targetPort: 80
selector:
app: {{ .Release.Name }}-web
type: {{ .Values.serviceType }}

View File

@@ -0,0 +1,6 @@
# number of replicas for the web Deployment:
replicaCount: 2
# port for the Service to listen on:
servicePort: 8012
# type of the Service:
serviceType: LoadBalancer