-
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? #23
base: main
Are you sure you want to change the base?
Solution? #23
Changes from 7 commits
5e38420
ee9dbfe
03a1892
966402e
1a0e7d4
a67b4d4
5f548f0
0789b39
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" | ||
|
||
dependencies: | ||
- name: mysql |
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,6 @@ | ||
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,15 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ .Chart.Name }} | ||
namespace: {{ .Values.mysql.namespace }} | ||
labels: | ||
app: {{ .Chart.Name }} | ||
data: | ||
init.sql: | | ||
GRANT ALL PRIVILEGES ON app_db.* TO 'app_user'@'%'; | ||
USE app_db; | ||
CREATE TABLE counter ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
value INT | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: {{ .Values.mysql.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.mysql.namespace }} | ||
type: Opaque | ||
data: | ||
{{- range $k, $v := .Values.mysql.secrets }} | ||
{{ $k }}: {{ $v | b64enc}} | ||
{{- end }} | ||
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. Add Eof(End-of-file), need to add blank line at the end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Headless service for stable DNS entries of StatefulSet members. | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ .Chart.Name }} | ||
namespace: {{ .Values.mysql.namespace }} | ||
spec: | ||
selector: | ||
app: {{ .Chart.Name }} | ||
ports: | ||
- name: {{ .Chart.Name }} | ||
port: {{ .Values.mysql.port }} | ||
clusterIP: {{ .Values.mysql.service.clusterIP }} | ||
|
||
# pod-name.service-name.namespace.svc.cluster.local | ||
# pod-name.service-name | ||
# mysql-0.mysql.mysql.svc.cluster.local | ||
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 don't need to leave these comments in the PR |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: {{ .Chart.Name }} | ||
namespace: {{ .Values.mysql.namespace }} | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: {{ .Chart.Name }} | ||
replicas: {{ .Values.mysql.replicas }} | ||
serviceName: {{ .Chart.Name }} | ||
template: | ||
metadata: | ||
labels: | ||
app: {{ .Chart.Name }} | ||
spec: | ||
containers: | ||
- name: {{ .Chart.Name }} | ||
image: {{ .Values.mysql.image.repository}}:{{ .Values.mysql.image.tag}} | ||
env: | ||
{{- range $k, $v := .Values.mysql.secrets }} | ||
- name: {{ $k }} | ||
valueFrom: | ||
secretKeyRef: | ||
name: mysql-secrets | ||
key: {{ $k }} | ||
{{- end }} | ||
- name: MYSQL_DATABASE | ||
value: app_db | ||
ports: | ||
- name: {{ .Chart.Name }} | ||
containerPort: {{ .Values.mysql.port }} | ||
volumeMounts: | ||
- name: data | ||
mountPath: /var/lib/mysql | ||
subPath: mysql | ||
- name: config-map | ||
mountPath: /docker-entrypoint-initdb.d | ||
resources: | ||
requests: | ||
cpu: {{ .Values.mysql.resources.requests.cpu }} | ||
memory: {{ .Values.mysql.resources.requests.memory }} | ||
limits: | ||
cpu: {{ .Values.mysql.resources.limits.cpu }} | ||
memory: {{ .Values.mysql.resources.limits.memory }} | ||
livenessProbe: | ||
exec: | ||
command: ["mysqladmin", "ping"] | ||
initialDelaySeconds: 30 | ||
periodSeconds: 10 | ||
timeoutSeconds: 5 | ||
readinessProbe: | ||
exec: | ||
command: ["mysqladmin", "ping"] | ||
initialDelaySeconds: 5 | ||
periodSeconds: 2 | ||
timeoutSeconds: 1 | ||
volumes: | ||
- name: config-map | ||
configMap: | ||
name: {{ .Chart.Name }} | ||
tolerations: | ||
- key: {{ .Values.mysql.tolerations.key}} | ||
operator: {{ .Values.mysql.tolerations.operator}} | ||
value: {{ .Values.mysql.tolerations.value}} | ||
effect: {{ .Values.mysql.tolerations.effect}} | ||
affinity: | ||
podAntiAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
- labelSelector: | ||
matchExpressions: | ||
- key: {{ .Values.mysql.affinity.key }} | ||
operator: {{ .Values.mysql.affinity.operator }} | ||
values: | ||
- {{ .Values.mysql.affinity.values }} | ||
topologyKey: {{ .Values.mysql.affinity.topologyKey }} | ||
nodeAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: {{ .Values.mysql.affinity.nodeAffinity.key }} | ||
operator: {{ .Values.mysql.affinity.nodeAffinity.operator }} | ||
values: | ||
- {{ .Values.mysql.affinity.nodeAffinity.values }} | ||
volumeClaimTemplates: | ||
- metadata: | ||
name: data | ||
spec: | ||
accessModes: ["ReadWriteOnce"] | ||
resources: | ||
requests: | ||
storage: {{ .Values.mysql.storage.size }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
mysql: | ||
namespace: mysql | ||
|
||
image: | ||
repository: mysql | ||
tag: 8.0 | ||
replicas: 2 | ||
port: 3306 | ||
|
||
service: | ||
clusterIP: None | ||
|
||
secrets: | ||
MYSQL_ROOT_PASSWORD: "1234" | ||
MYSQL_USER: "app_user" | ||
MYSQL_PASSWORD: "1234" | ||
|
||
resources: | ||
requests: | ||
cpu: "500m" | ||
memory: "1Gi" | ||
limits: | ||
cpu: "1" | ||
memory: "2Gi" | ||
storage: | ||
size: "2Gi" | ||
|
||
tolerations: | ||
key: "app" | ||
operator: "Equal" | ||
value: "mysql" | ||
effect: "NoSchedule" | ||
|
||
affinity: | ||
key: "app" | ||
operator: In | ||
values: "mysql" | ||
topologyKey: "kubernetes.io/hostname" | ||
nodeAffinity: | ||
key: "app" | ||
operator: In | ||
values: "mysql" |
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.todoapp.namespace }} | ||
spec: | ||
type: {{ .Values.todoapp.service.type}} | ||
selector: | ||
app: {{ .Chart.Name }} | ||
ports: | ||
- protocol: TCP | ||
port: {{ .Values.todoapp.service.port}} | ||
targetPort: {{ .Values.todoapp.service.targetPort }} |
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.todoapp.namespace }} | ||
data: | ||
PYTHONUNBUFFERED: "1" | ||
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. Add Eof(End-of-file), need to add blank line at the end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ .Release.Name }}-{{ .Chart.Name }} | ||
namespace: {{ .Values.todoapp.namespace }} | ||
spec: | ||
strategy: | ||
type: RollingUpdate | ||
rollingUpdate: | ||
maxSurge: {{ .Values.todoapp.rollingUpdate.maxSurge}} | ||
maxUnavailable: {{ .Values.todoapp.rollingUpdate.maxUnavailable}} | ||
selector: | ||
matchLabels: | ||
app: {{ .Chart.Name }} | ||
template: | ||
metadata: | ||
labels: | ||
app: {{ .Chart.Name }} | ||
spec: | ||
serviceAccountName: {{ .Chart.Name }}-reader | ||
containers: | ||
- name: {{ .Chart.Name }} | ||
image: "{{ .Values.todoapp.image.repository}}: {{ .Values.todoapp.image.tag }}" | ||
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 }} | ||
cpu: {{ .Values.todoapp.resources.requests.cpu }} | ||
limits: | ||
memory: {{ .Values.todoapp.resources.limits.memory }} | ||
cpu: {{ .Values.todoapp.resources.limits.cpu }} | ||
env: | ||
- name: PYTHONUNBUFFERED | ||
valueFrom: | ||
configMapKeyRef: | ||
name: {{ .Chart.Name }}-config | ||
key: PYTHONUNBUFFERED | ||
{{- range $k, $v := .Values.todoapp.secrets }} | ||
- name: {{ $k }} | ||
valueFrom: | ||
secretKeyRef: | ||
name: todoapp-secret | ||
key: {{ $k }} | ||
{{- 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: {{ .Chart.Name }}-pvc-data | ||
- name: app-secrets-volume | ||
secret: | ||
secretName: {{ .Chart.Name }}-secret | ||
- name: app-config-volume | ||
configMap: | ||
name: {{ .Chart.Name }}-config | ||
affinity: | ||
nodeAffinity: | ||
preferredDuringSchedulingIgnoredDuringExecution: | ||
- weight: 1 | ||
preference: | ||
matchExpressions: | ||
- key: app | ||
operator: In | ||
values: | ||
- kube2py | ||
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. Add Eof(End-of-file), need to add blank line at the end |
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.todoapp.namespace }} | ||
spec: | ||
scaleTargetRef: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
name: {{ .Release.Name}} - {{ .Chart.Name }} | ||
minReplicas: {{ .Values.todoapp.autoscaling.minReplicas }} | ||
maxReplicas: {{ .Values.todoapp.autoscaling.maxReplicas }} | ||
metrics: | ||
- type: Resource | ||
resource: | ||
name: cpu | ||
target: | ||
type: Utilization | ||
averageUtilization: {{ .Values.todoapp.autoscaling.targetCPUUtilizationPercentage }} | ||
- type: Resource | ||
resource: | ||
name: memory | ||
target: | ||
type: Utilization | ||
averageUtilization: {{ .Values.todoapp.autoscaling.targetMemoryUtilizationPercentage }} |
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.
Add Eof(End-of-file), need to add blank line at the end