-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution:1.0 #2
base: main
Are you sure you want to change the base?
Solution:1.0 #2
Changes from 2 commits
00bbe6e
e408d60
00f32a2
9bee561
c584c8a
d4d3f34
c2bb6bc
120495f
5e13a1f
3268fdb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v2 | ||
name: todoapp | ||
description: A Helm chart for Kubernetes | ||
|
||
type: application | ||
|
||
version: 0.1.0 | ||
|
||
appVersion: "1.16.0" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v2 | ||
name: mysql | ||
description: A Helm chart for Kubernetes | ||
|
||
type: application | ||
|
||
version: 0.1.0 | ||
|
||
appVersion: "1.16.0" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ .Chart.Name }} | ||
namespace: {{ .Values.global.namespace }} | ||
labels: | ||
app: {{ .Chart.Name }} | ||
data: | ||
init.sql: {{ .Values.mysql.config.init }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: {{ .Values.global.namespace }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: {{ .Chart.Name }}-secrets | ||
namespace: {{ .Values.global.namespace }} | ||
type: Opaque | ||
data: | ||
{{-range $k, $v := .Values.mysql.secret }} | ||
{{ $k | upper }}: {{ $v | quote }} | ||
{{- end }} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,13 @@ | ||||||
# Headless service for stable DNS entries of StatefulSet members. | ||||||
apiVersion: v1 | ||||||
kind: Service | ||||||
metadata: | ||||||
name: {{ .Chart.Name }} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
namespace: {{ .Values.global.namespace }} | ||||||
spec: | ||||||
selector: | ||||||
app: {{ .Chart.Name }} | ||||||
ports: | ||||||
- name: {{ .Values.mysql.service.ports.name }} | ||||||
port: {{ .Values.mysql.service.ports.port }} | ||||||
clusterIP: {{ .Values.mysql.service.clusterIP }} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,58 @@ | ||||||
apiVersion: apps/v1 | ||||||
kind: StatefulSet | ||||||
metadata: | ||||||
name: {{ .Chart.Name }} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
namespace: {{ .Values.global.namespace }} | ||||||
spec: | ||||||
selector: | ||||||
matchLabels: | ||||||
app: {{ .Chart.Name }} | ||||||
replicas: {{ .Values.mysql.statefulSet }} | ||||||
serviceName: {{ .Chart.Name }} | ||||||
template: | ||||||
metadata: | ||||||
labels: | ||||||
app: {{ .Chart.Name }} | ||||||
spec: | ||||||
containers: | ||||||
- name: {{ .Values.mysql.statefulSet.name }} | ||||||
image: {{ .Values.mysql.statefulSet.repository }}:{{ .Values.mysql.statefulSet.version }} | ||||||
env: | ||||||
{{- range $k := .Values.mysql.secret }} | ||||||
- name: {{ $k }} | ||||||
valueFrom: | ||||||
secretKeyRef: | ||||||
name: {{ .Chart.Name }}-secrets | ||||||
key: {{ $k }} | ||||||
{{- end }} | ||||||
value: app_db | ||||||
ports: | ||||||
- name: mysql | ||||||
containerPort: 3306 | ||||||
volumeMounts: | ||||||
- name: data | ||||||
mountPath: /var/lib/mysql | ||||||
subPath: mysql | ||||||
- name: config-map | ||||||
mountPath: /docker-entrypoint-initdb.d | ||||||
resources: | ||||||
requests: | ||||||
{{ .Values.mysql.statefulSet.resources.requests }} | ||||||
livenessProbe: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could import the whole block from values. And same for other below |
||||||
{{ .Values.mysql.statefulSet.livenessProbe }} | ||||||
readinessProbe: | ||||||
{{ .Values.mysql.statefulSet.readinessProbe }} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not changed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, resources, livenessProbe and readinesS on the same level in code line maybe will be better to keep them as 3 lines |
||||||
volumes: | ||||||
- name: config-map | ||||||
configMap: | ||||||
name: mysql | ||||||
tolerations: | ||||||
{{ .Values.mysql.statefulSet.tolerations }} | ||||||
volumeClaimTemplates: | ||||||
- metadata: | ||||||
name: data | ||||||
spec: | ||||||
accessModes: ["ReadWriteOnce"] | ||||||
resources: | ||||||
requests: | ||||||
storage: {{ .Values.mysql.statefulSet.storage }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
mysql: | ||
config: | ||
init: | | ||
GRANT ALL PRIVILEGES ON app_db.* TO 'app_user'@'%'; | ||
USE app_db; | ||
CREATE TABLE counter ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
value INT | ||
); | ||
|
||
service: | ||
ports: | ||
name: mysql | ||
port: 3306 | ||
clusterIP: None | ||
|
||
secret: | ||
MYSQL_ROOT_PASSWORD: MTIzNA== | ||
MYSQL_USER: YXBwX3VzZXI= | ||
MYSQL_PASSWORD: MTIzNA== | ||
|
||
statefulSet: | ||
replicas: 2 | ||
name: mysql | ||
repository: mysql | ||
version: 8.0 | ||
storage: 2Gi | ||
|
||
resources: | ||
requests: | ||
cpu: 500m | ||
memory: 1Gi | ||
|
||
livenessProbe: | ||
exec: | ||
command: ["mysqladmin", "ping"] | ||
initialDelaySeconds: 30 | ||
periodSeconds: 10 | ||
timeoutSeconds: 5 | ||
|
||
readinessProbe: | ||
exec: | ||
command: ["mysqladmin", "ping"] | ||
initialDelaySeconds: 5 | ||
periodSeconds: 2 | ||
timeoutSeconds: 1 | ||
|
||
affinity: | ||
podAntiAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
- labelSelector: | ||
matchExpressions: | ||
- key: "app" | ||
operator: In | ||
values: | ||
- mysql | ||
topologyKey: "kubernetes.io/hostname" | ||
nodeAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: "app" | ||
operator: In | ||
values: | ||
- "mysql" | ||
|
||
tolerations: | ||
- key: "app" | ||
operator: "Equal" | ||
value: "mysql" | ||
effect: "NoSchedule" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ .Chart.Name }}-service | ||
namespace: {{ .Values.global.namespace }} | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
app: {{ .Chart.Name }} | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
targetPort: 8080 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ .Chart.Name }}-config | ||
namespace: {{ .Values.global.namespace }} | ||
data: | ||
PYTHONUNBUFFERED: {{ .Values.todoapp.configs.PYTHONUNBUFFERED }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ .Release.Name }}-{{ .Chart.Name }} | ||
namespace: {{ .Values.global.namespace }} | ||
spec: | ||
strategy: | ||
type: RollingUpdate | ||
rollingUpdate: | ||
maxSurge: {{ .Values.todoapp.rollingUpdate.maxSurge }} | ||
maxUnavailable: {{ .Values.todoapp.rollingUpdate.maxSurge }} | ||
selector: | ||
matchLabels: | ||
app: {{ .Chart.Name }} | ||
template: | ||
metadata: | ||
labels: | ||
app: {{ .Chart.Name }} | ||
spec: | ||
serviceAccountName: {{ .Chart.Name }}-secrets-reader | ||
containers: | ||
- name: {{ .Values.todoapp.image.name }} | ||
image: {{ .Values.todoapp.image.repository }}:{{ .Values.todoapp.image.version }} | ||
volumeMounts: | ||
- name: data | ||
mountPath: /app/data | ||
- name: app-secrets-volume | ||
mountPath: "/app/secrets" | ||
readOnly: true | ||
- name: app-config-volume | ||
mountPath: "/app/configs" | ||
readOnly: true | ||
resources: | ||
requests: | ||
memory: {{ .Values.todoapp.resources.requests.memory | quote }} | ||
cpu: {{ .Values.todoapp.resources.requests.cpu | quote }} | ||
limits: | ||
memory: {{ .Values.todoapp.resources.limits.memory | quote }} | ||
cpu: {{ .Values.todoapp.resources.limits.cpu | quote }} | ||
Comment on lines
+33
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could be imported whole block. |
||
env: | ||
- name: PYTHONUNBUFFERED | ||
valueFrom: | ||
configMapKeyRef: | ||
name: {{ .Chart.Name }}-config | ||
key: PYTHONUNBUFFERED | ||
{{- range $k := .Values.todoapp.secret }} | ||
- name: {{ $k | upper }} | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Chart.Name }}-secret | ||
key: {{ $k | upper }} | ||
{{- end }} | ||
ports: | ||
- containerPort: 8080 | ||
livenessProbe: | ||
httpGet: | ||
path: api/health | ||
port: 8080 | ||
initialDelaySeconds: 60 | ||
periodSeconds: 5 | ||
readinessProbe: | ||
httpGet: | ||
path: api/ready | ||
port: 8080 | ||
initialDelaySeconds: 5 | ||
periodSeconds: 5 | ||
volumes: | ||
- name: data | ||
persistentVolumeClaim: | ||
claimName: pvc-data | ||
- name: app-secrets-volume | ||
secret: | ||
secretName: app-secret | ||
- name: app-config-volume | ||
configMap: | ||
name: app-config | ||
affinity: | ||
{{ .Values.todoapp.affinity }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: autoscaling/v2 | ||
kind: HorizontalPodAutoscaler | ||
metadata: | ||
name: {{ .Chart.Name }} | ||
namespace: {{ .Values.global.namespace }} | ||
spec: | ||
scaleTargetRef: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
name: {{ .Release.Name }}-{{ .Chart.Name }} | ||
minReplicas: {{ .Values.todoapp.hpa.minReplicas }} | ||
maxReplicas: {{ .Values.todoapp.hpa.maxReplicas }} | ||
metrics: | ||
- type: Resource | ||
resource: | ||
name: cpu | ||
target: | ||
type: Utilization | ||
averageUtilization: {{ .Values.todoapp.hpa.cpu.averageUtilization }} | ||
- type: Resource | ||
resource: | ||
name: memory | ||
target: | ||
type: Utilization | ||
averageUtilization: {{ .Values.todoapp.hpa.memory.averageUtilization }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: {{ .Chart.Name }}-ingress | ||
namespace: {{ .Values.global.namespace }} | ||
annotations: | ||
nginx.ingress.kubernetes.io/rewrite-target: /$2 | ||
spec: | ||
rules: | ||
- http: | ||
paths: | ||
- pathType: Prefix | ||
path: /(|$)(.*) | ||
backend: | ||
service: | ||
name: {{ .Chart.Name }}-service | ||
port: | ||
number: 80 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ .Chart.Name }}-nodeport | ||
namespace: {{ .Values.global.namespace }} | ||
spec: | ||
type: NodePort | ||
selector: | ||
app: {{ .Chart.Name }} | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
targetPort: 8080 | ||
nodePort: 30007 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use chart name as prefix, not a full name:
{{ .Chart.Name }}-configmap