diff --git a/.gitignore b/.gitignore index 68bc17f..10cc536 100644 --- a/.gitignore +++ b/.gitignore @@ -56,7 +56,6 @@ cover/ *.pot # Django stuff: -*.log local_settings.py db.sqlite3 db.sqlite3-journal diff --git a/.infrastructure/helm-chart/todoapp/.helmignore b/.infrastructure/helm-chart/todoapp/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/.helmignore @@ -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/ diff --git a/.infrastructure/helm-chart/todoapp/Chart.yaml b/.infrastructure/helm-chart/todoapp/Chart.yaml new file mode 100644 index 0000000..69b3db0 --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/Chart.yaml @@ -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 diff --git a/.infrastructure/helm-chart/todoapp/charts/mysql/Chart.yaml b/.infrastructure/helm-chart/todoapp/charts/mysql/Chart.yaml new file mode 100644 index 0000000..2f18252 --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/charts/mysql/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: mysql +description: A Helm chart for Kubernetes +type: application +version: 0.1.0 +appVersion: "1.16.0" diff --git a/.infrastructure/helm-chart/todoapp/charts/mysql/templates/configMap.yml b/.infrastructure/helm-chart/todoapp/charts/mysql/templates/configMap.yml new file mode 100644 index 0000000..f20dbd9 --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/charts/mysql/templates/configMap.yml @@ -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 + ); diff --git a/.infrastructure/helm-chart/todoapp/charts/mysql/templates/ns.yml b/.infrastructure/helm-chart/todoapp/charts/mysql/templates/ns.yml new file mode 100644 index 0000000..d5a8a94 --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/charts/mysql/templates/ns.yml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: {{ .Values.mysql.namespace }} diff --git a/.infrastructure/helm-chart/todoapp/charts/mysql/templates/secret.yml b/.infrastructure/helm-chart/todoapp/charts/mysql/templates/secret.yml new file mode 100644 index 0000000..bf223af --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/charts/mysql/templates/secret.yml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Chart.Name }}-secrets + namespace: {{ .Values.mysql.namespace }} +type: Opaque +data: + {{- range $key, $value := .Values.mysql.secrets }} + {{ $key | upper }}: {{ $value }} + {{- end }} diff --git a/.infrastructure/helm-chart/todoapp/charts/mysql/templates/service.yml b/.infrastructure/helm-chart/todoapp/charts/mysql/templates/service.yml new file mode 100644 index 0000000..46364e8 --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/charts/mysql/templates/service.yml @@ -0,0 +1,12 @@ +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 }} diff --git a/.infrastructure/helm-chart/todoapp/charts/mysql/templates/statefulSet.yml b/.infrastructure/helm-chart/todoapp/charts/mysql/templates/statefulSet.yml new file mode 100644 index 0000000..eea2bfc --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/charts/mysql/templates/statefulSet.yml @@ -0,0 +1,77 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ .Chart.Name }} + namespace: {{ .Values.mysql.namespace }} +spec: + replicas: {{ .Values.mysql.replicas }} + serviceName: {{ .Chart.Name }} + selector: + matchLabels: + app: {{ .Chart.Name }} + template: + metadata: + labels: + app: {{ .Chart.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.mysql.image.repository }}:{{ .Values.mysql.image.tag }}" + env: + {{- range $key, $val := .Values.mysql.secrets }} + - name: {{ $key }} + valueFrom: + secretKeyRef: + name: mysql-secrets + key: {{ $key }} + {{- end }} + - name: MYSQL_DATABASE + value: app_db + ports: + - name: {{ .Chart.Name }} + containerPort: {{ .Values.mysql.port }} + volumeMounts: + - name: data + mountPath: /var/lib/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 + readinessProbe: + exec: + command: ["mysqladmin", "ping"] + initialDelaySeconds: 5 + periodSeconds: 2 + volumes: + - name: config-map + configMap: + name: {{ .Chart.Name }} + tolerations: + {{ toYaml .Values.mysql.tolerations | nindent 8 }} + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: "app" + operator: In + values: + - {{ .Chart.Name }} + volumeClaimTemplates: + - metadata: + name: data + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: {{ .Values.mysql.storage.size }} diff --git a/.infrastructure/helm-chart/todoapp/charts/mysql/values.yaml b/.infrastructure/helm-chart/todoapp/charts/mysql/values.yaml new file mode 100644 index 0000000..584c946 --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/charts/mysql/values.yaml @@ -0,0 +1,49 @@ +mysql: + namespace: mysql + image: + repository: mysql + tag: 8.0 + replicas: 2 + port: 3306 + + service: + clusterIP: None + + secrets: + MYSQL_ROOT_PASSWORD: "MTIzNA==" + MYSQL_USER: "YXBwX3VzZXI=" + MYSQL_PASSWORD: "MTIzNA==" + + resources: + requests: + cpu: "500m" + memory: "1Gi" + limits: + cpu: "1" + memory: "2Gi" + storage: + size: "2Gi" + + tolerations: + - key: "app" + operator: "Equal" + value: "mysql" + effect: "NoSchedule" + 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" diff --git a/.infrastructure/helm-chart/todoapp/templates/clusterIp.yml b/.infrastructure/helm-chart/todoapp/templates/clusterIp.yml new file mode 100644 index 0000000..06c1a2d --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/templates/clusterIp.yml @@ -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 }} diff --git a/.infrastructure/helm-chart/todoapp/templates/configMap.yml b/.infrastructure/helm-chart/todoapp/templates/configMap.yml new file mode 100644 index 0000000..8bf9081 --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/templates/configMap.yml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Chart.Name }}-config + namespace: {{ .Values.todoapp.namespace }} +data: + PYTHONUNBUFFERED: "1" diff --git a/.infrastructure/helm-chart/todoapp/templates/deployment.yml b/.infrastructure/helm-chart/todoapp/templates/deployment.yml new file mode 100644 index 0000000..761fb0f --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/templates/deployment.yml @@ -0,0 +1,79 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }} + namespace: {{ .Values.todoapp.namespace }} +spec: + replicas: {{ .Values.todoapp.replicaCount | default 1 }} + strategy: + type: RollingUpdate + rollingUpdate: + maxSurge: {{ .Values.todoapp.rollingUpdate.maxSurge | default 1 }} + maxUnavailable: {{ .Values.todoapp.rollingUpdate.maxUnavailable | default 1 }} + selector: + matchLabels: + app: {{ .Chart.Name }} + template: + metadata: + labels: + app: {{ .Chart.Name }} + spec: + serviceAccountName: {{ .Chart.Name }}-secrets-reader + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.todoapp.image.repository }}:{{ .Values.todoapp.image.tag }}" + ports: + - containerPort: {{ .Values.todoapp.service.targetPort }} + env: + - name: PYTHONUNBUFFERED + valueFrom: + configMapKeyRef: + name: {{ .Chart.Name }}-config + key: PYTHONUNBUFFERED + {{- range $key, $value := .Values.todoapp.secrets }} + - name: {{ $key }} + valueFrom: + secretKeyRef: + name: todoapp-secret + key: {{ $key }} + {{- end }} + 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 }} + livenessProbe: + {{- toYaml .Values.todoapp.livenessProbe | nindent 10 }} + readinessProbe: + {{- toYaml .Values.todoapp.readinessProbe | nindent 10 }} + volumeMounts: + - name: data + mountPath: /app/data + - name: app-secrets-volume + mountPath: /app/secrets + readOnly: true + - name: app-config-volume + mountPath: /app/configs + readOnly: true + 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 diff --git a/.infrastructure/helm-chart/todoapp/templates/hpa.yml b/.infrastructure/helm-chart/todoapp/templates/hpa.yml new file mode 100644 index 0000000..8f6e271 --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/templates/hpa.yml @@ -0,0 +1,25 @@ +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Chart.Name }}-hpa + 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 }} diff --git a/.infrastructure/helm-chart/todoapp/templates/ingress.yml b/.infrastructure/helm-chart/todoapp/templates/ingress.yml new file mode 100644 index 0000000..95f2e6a --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/templates/ingress.yml @@ -0,0 +1,18 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Chart.Name }}-ingress + namespace: {{ .Values.todoapp.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 diff --git a/.infrastructure/helm-chart/todoapp/templates/nodeport.yml b/.infrastructure/helm-chart/todoapp/templates/nodeport.yml new file mode 100644 index 0000000..f038370 --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/templates/nodeport.yml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }}-nodeport + namespace: {{ .Values.todoapp.namespace }} +spec: + type: NodePort + selector: + app: {{ .Chart.Name }} + ports: + - protocol: TCP + port: 80 + targetPort: 8080 + nodePort: 30007 diff --git a/.infrastructure/helm-chart/todoapp/templates/ns.yml b/.infrastructure/helm-chart/todoapp/templates/ns.yml new file mode 100644 index 0000000..5b90b3f --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/templates/ns.yml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: {{ .Values.todoapp.namespace }} diff --git a/.infrastructure/helm-chart/todoapp/templates/pv.yml b/.infrastructure/helm-chart/todoapp/templates/pv.yml new file mode 100644 index 0000000..ae6db47 --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/templates/pv.yml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: {{ .Chart.Name }}-pv-data + namespace: {{ .Values.todoapp.namespace }} +spec: + storageClassName: standard + persistentVolumeReclaimPolicy: Delete + accessModes: + - ReadWriteMany + capacity: + storage: {{ .Values.todoapp.volumes.persistentVolume.capacity }} + hostPath: + path: /data/ diff --git a/.infrastructure/helm-chart/todoapp/templates/pvc.yml b/.infrastructure/helm-chart/todoapp/templates/pvc.yml new file mode 100644 index 0000000..4d0d27d --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/templates/pvc.yml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Chart.Name }}-pvc-data + namespace: {{ .Values.todoapp.namespace }} +spec: + volumeName: {{ .Chart.Name }}-pv-data + accessModes: + - ReadWriteMany + resources: + requests: + storage: {{ .Values.todoapp.volumes.persistentVolumeClaim.requestStorage }} diff --git a/.infrastructure/helm-chart/todoapp/templates/rbac.yml b/.infrastructure/helm-chart/todoapp/templates/rbac.yml new file mode 100644 index 0000000..268b4a1 --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/templates/rbac.yml @@ -0,0 +1,30 @@ +kind: ServiceAccount +apiVersion: v1 +metadata: + name: {{ .Chart.Name }}-secrets-reader + namespace: {{ .Values.todoapp.namespace }} + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + namespace: {{ .Values.todoapp.namespace }} + name: secrets-reader +rules: +- apiGroups: [""] + resources: ["secrets"] + verbs: ["get", "watch", "list"] + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: secrets-reader-binding + namespace: {{ .Values.todoapp.namespace }} +subjects: +- kind: ServiceAccount + name: secrets-reader +roleRef: + kind: Role + name: secrets-reader + apiGroup: rbac.authorization.k8s.io diff --git a/.infrastructure/helm-chart/todoapp/templates/secret.yml b/.infrastructure/helm-chart/todoapp/templates/secret.yml new file mode 100644 index 0000000..2f821f8 --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/templates/secret.yml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Chart.Name }}-secret + namespace: {{ .Values.todoapp.namespace }} +type: Opaque +data: +{{- range $key, $val:= .Values.todoapp.secrets }} + {{ $key | upper }}: {{ $val }} +{{- end }} diff --git a/.infrastructure/helm-chart/todoapp/values.yaml b/.infrastructure/helm-chart/todoapp/values.yaml new file mode 100644 index 0000000..78ab37b --- /dev/null +++ b/.infrastructure/helm-chart/todoapp/values.yaml @@ -0,0 +1,69 @@ +todoapp: + namespace: todoapp + image: + repository: ikulyk404/todoapp + tag: "4.0.1" + replicaCount: 1 + + secrets: + SECRET_KEY: "QGUyKHl4KXYmdGdoM19zPTB5amEtaSFkcGVieHN6XmRnNDd4KS1rJmtxXzN6Zio5ZSoK" + DB_NAME: "YXBwX2RiCg==" + DB_USER: "YXBwX3VzZXI=" + DB_PASSWORD: "MTIzNA==" + DB_HOST: "bXlzcWwtMC5teXNxbC5teXNxbC5zdmMuY2x1c3Rlci5sb2NhbAo=" + + rollingUpdate: + maxSurge: "25%" + maxUnavailable: 1 + + service: + type: ClusterIP + port: 80 + targetPort: 8080 + + ingress: + enabled: false + className: "" + annotations: {} + + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + + resources: + limits: + cpu: "100m" + memory: "128Mi" + requests: + cpu: "100m" + memory: "128Mi" + + livenessProbe: + httpGet: + path: "api/health" + port: 8080 + initialDelaySeconds: 60 + periodSeconds: 5 + + readinessProbe: + httpGet: + path: "api/ready" + port: 8080 + initialDelaySeconds: 5 + periodSeconds: 5 + + autoscaling: + enabled: true + minReplicas: 2 + maxReplicas: 5 + targetCPUUtilizationPercentage: 70 + targetMemoryUtilizationPercentage: 70 + + volumes: + persistentVolume: + capacity: "1Gi" + persistentVolumeClaim: + requestStorage: "1Gi" diff --git a/README.md b/README.md index 93f589c..672f5dc 100644 --- a/README.md +++ b/README.md @@ -1,76 +1,44 @@ -# Django ToDo list -This is a todo list web application with basic features of most web apps, i.e., accounts/login, API, and interactive UI. To do this task, you will need: +# Kubernetes Manifest for Todoapp -- CSS | [Skeleton](http://getskeleton.com/) -- JS | [jQuery](https://jquery.com/) +This repository contains the Kubernetes manifests for deploying a ToDo app using Helm. Below are the instructions for setting up the environment and deploying the application. -## Explore +## Instructions -Try it out by installing the requirements (the following commands work only with Python 3.8 and higher, due to Django 4): +### Environment Setup -``` -pip install -r requirements.txt +Install Kind: Use kind to spin up a Kubernetes cluster. You can find the configuration file cluster.yml within the repository. Use it to create a cluster with the necessary specifications. + +```bash +kind create cluster --config=cluster.yml ``` -Create a database schema: +### Helm Chart install +```bash +./bootstrap.sh ``` -python manage.py migrate + +### Check active namespaces + +```bash +kubectl get ns ``` -And then start the server (default is http://localhost:8000): +### Check helm list +```bash +helm list ``` -python manage.py runserver + +### Check helm release history + +```bash +helm history todoapp ``` -Now you can browse the [API](http://localhost:8000/api/) or start on the [landing page](http://localhost:8000/). - -## Task - -Create a kubernetes manifest for a pod which will containa ToDo app container: - -1. Fork this repository. -1. Use `kind` to spin up a cluster from a `cluster.yml` configuration file. -1. Inspect Nodes for Labels and Taints -1. Taint nodes labeled with `app=mysql` with `app=mysql:NoSchedule` -1. Create a helm chart named `todoapp` inside a `helm-chart` directory -1. `todoapp` helm chart requirements: - 1. Namespace name should be controlled from a `values.yaml` file - 1. Use `.Chart.Name` as a prefix for all resources names - 1. Secrets should be controlled from a `values.yaml` file - 1. Secrets `data` should be popualted by a `range` function - 1. Inside the deployment use `range` to map secrets as environment variables - 1. Resources requests and limits should controlled from a `values.yaml` file - 1. RollingUpdate parameters should be controlled from a `values.yaml` file - 1. Image repository and tag should be controlled from a `values.yaml` file - 1. Deployment node affinity parameters should be controlled from a `values.yaml` file (key and values) - 1. `hpa` min and max replicas should be controlled from a `values.yaml` file - 1. `hpa` average CPU and Memory utilization should be controlled from a `values.yaml` file - 1. `pv` capacity should be controlled from a `values.yaml` file - 1. `pvc` requests storage should be controlled from a `values.yaml` file - 1. Service Account Name inside both `Deployment` and all rbac objects should be controld from a `values.yaml` file -1. Creata a sub-chart called `mysql` inside a `charts` directory of the `todoapp` helm chart -1. `mysql` helm chart requirements: - 1. Namespace name should be controlled from a `values.yaml` file - 1. Use `.Chart.Name` as a prefix for all resources names - 1. Secrets should be controlled from a `values.yaml` file - 1. Secrets `data` should be popualted by a `range` function - 1. StateFulSet's Replicas should be controlled from a `values.yaml` file - 1. Image repository and tag should be controlled from a `values.yaml` file - 1. `pvc` requests storage should be controlled from a `values.yaml` file - 1. Affinity and Toleration parameters should be controlled from a `values.yaml` file - 1. Resource requests and limits should controlled from a `values.yaml` file -1. Add explicit dependencies between `todoapp` and `mysql` charts - 1. Inside the Chart.yaml file of todoapp chart, add lines - ``` - dependencies: - - name: mysql - ``` - -10. `bootstrap.sh` should containe all commands to deploy prerequsites and the `todoapp` helm chart -11. Deploy helm chart to your `kind` cluster -11. Run command `kubectl get all,cm,secret,ing -A` and put the output in a file called `output.log` in a root of the repository -12. `README.md` should have instructuions on how to validate the changes -13. Create PR with your changes and attach it for validation on a platform. +### Command delete release + +```bash +helm uninstall todoapp +``` diff --git a/bootstrap.sh b/bootstrap.sh index 2d534d7..7fa6859 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,20 +1 @@ -#!/bin/bash -kubectl apply -f .infrastructure/mysql/ns.yml -kubectl apply -f .infrastructure/mysql/configMap.yml -kubectl apply -f .infrastructure/mysql/secret.yml -kubectl apply -f .infrastructure/mysql/service.yml -kubectl apply -f .infrastructure/mysql/statefulSet.yml - -kubectl apply -f .infrastructure/app/ns.yml -kubectl apply -f .infrastructure/app/pv.yml -kubectl apply -f .infrastructure/app/pvc.yml -kubectl apply -f .infrastructure/app/secret.yml -kubectl apply -f .infrastructure/app/configMap.yml -kubectl apply -f .infrastructure/app/clusterIp.yml -kubectl apply -f .infrastructure/app/nodeport.yml -kubectl apply -f .infrastructure/app/hpa.yml -kubectl apply -f .infrastructure/app/deployment.yml - -# Install Ingress Controller -kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml -# kubectl apply -f .infrastructure/ingress/ingress.yml +helm install todoapp .infrastructure/helm-chart/todoapp diff --git a/output.log b/output.log new file mode 100644 index 0000000..cd5394a --- /dev/null +++ b/output.log @@ -0,0 +1,163 @@ +NAMESPACE NAME READY STATUS RESTARTS AGE +default pod/alertmanager-prometheus-kube-prometheus-alertmanager-0 2/2 Running 2 (4m16s ago) 6d +default pod/grafana-8c8f844f-86b4m 1/1 Running 1 (4m16s ago) 6d +default pod/prometheus-kube-prometheus-operator-74c5cfdb84-gjvn8 1/1 Running 2 (3m26s ago) 6d +default pod/prometheus-kube-prometheus-stack-grafana-74f59445f-xnpgv 3/3 Running 3 (4m16s ago) 6d +default pod/prometheus-kube-prometheus-stack-kube-state-metrics-7858dcswq5x 1/1 Running 2 (3m33s ago) 6d +default pod/prometheus-kube-prometheus-stack-prometheus-node-exporter-2mzbm 1/1 Running 1 (4m16s ago) 6d +default pod/prometheus-kube-prometheus-stack-prometheus-node-exporter-cwkxj 1/1 Running 1 (4m16s ago) 6d +default pod/prometheus-kube-prometheus-stack-prometheus-node-exporter-kc9d2 1/1 Running 1 (4m16s ago) 6d +default pod/prometheus-kube-prometheus-stack-prometheus-node-exporter-kwnkn 1/1 Running 1 (4m16s ago) 6d +default pod/prometheus-kube-prometheus-stack-prometheus-node-exporter-l7hmc 1/1 Running 1 (4m16s ago) 6d +default pod/prometheus-kube-prometheus-stack-prometheus-node-exporter-mgp7c 1/1 Running 1 (4m16s ago) 6d +default pod/prometheus-kube-prometheus-stack-prometheus-node-exporter-qp7qj 1/1 Running 1 (4m16s ago) 6d +default pod/prometheus-prometheus-kube-prometheus-prometheus-0 2/2 Running 2 (4m16s ago) 6d +kube-system pod/coredns-76f75df574-2pq95 1/1 Running 1 (4m16s ago) 7d1h +kube-system pod/coredns-76f75df574-vclxj 1/1 Running 1 (4m16s ago) 7d1h +kube-system pod/etcd-kind-control-plane 1/1 Running 0 4m6s +kube-system pod/kindnet-298w6 1/1 Running 1 (4m16s ago) 7d1h +kube-system pod/kindnet-2t554 1/1 Running 1 (4m16s ago) 7d1h +kube-system pod/kindnet-bj75p 1/1 Running 1 (4m16s ago) 7d1h +kube-system pod/kindnet-gcddz 1/1 Running 1 (4m16s ago) 7d1h +kube-system pod/kindnet-s2s87 1/1 Running 1 (4m16s ago) 7d1h +kube-system pod/kindnet-wp4lq 1/1 Running 1 (4m16s ago) 7d1h +kube-system pod/kindnet-zsmz2 1/1 Running 1 (4m16s ago) 7d1h +kube-system pod/kube-apiserver-kind-control-plane 1/1 Running 0 4m6s +kube-system pod/kube-controller-manager-kind-control-plane 1/1 Running 2 (4m16s ago) 7d1h +kube-system pod/kube-proxy-64nqm 1/1 Running 1 (4m16s ago) 7d1h +kube-system pod/kube-proxy-7486p 1/1 Running 1 (4m16s ago) 7d1h +kube-system pod/kube-proxy-g5mrm 1/1 Running 1 (4m16s ago) 7d1h +kube-system pod/kube-proxy-n9ch5 1/1 Running 1 (4m16s ago) 7d1h +kube-system pod/kube-proxy-vjfrm 1/1 Running 1 (4m16s ago) 7d1h +kube-system pod/kube-proxy-w5vrw 1/1 Running 1 (4m16s ago) 7d1h +kube-system pod/kube-proxy-wdvml 1/1 Running 1 (4m16s ago) 7d1h +kube-system pod/kube-scheduler-kind-control-plane 1/1 Running 2 (4m16s ago) 7d1h +local-path-storage pod/local-path-provisioner-7577fdbbfb-xn6jh 1/1 Running 2 (3m27s ago) 7d1h +mysql pod/mysql-0 1/1 Running 0 3m12s +mysql pod/mysql-1 1/1 Running 0 3m +todoapp pod/todoapp-todoapp-7cfbb4b546-jmd45 1/1 Running 2 (2m53s ago) 3m13s +todoapp pod/todoapp-todoapp-7cfbb4b546-xftmb 1/1 Running 2 (2m35s ago) 2m58s + +NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +default service/alertmanager-operated ClusterIP None 9093/TCP,9094/TCP,9094/UDP 6d +default service/grafana ClusterIP 10.96.116.141 80/TCP 6d +default service/kubernetes ClusterIP 10.96.0.1 443/TCP 7d1h +default service/prometheus-kube-prometheus-alertmanager ClusterIP 10.96.20.171 9093/TCP,8080/TCP 6d +default service/prometheus-kube-prometheus-operator ClusterIP 10.96.135.108 443/TCP 6d +default service/prometheus-kube-prometheus-prometheus ClusterIP 10.96.139.105 9090/TCP,8080/TCP 6d +default service/prometheus-kube-prometheus-stack-grafana ClusterIP 10.96.48.223 80/TCP 6d +default service/prometheus-kube-prometheus-stack-kube-state-metrics ClusterIP 10.96.39.75 8080/TCP 6d +default service/prometheus-kube-prometheus-stack-prometheus-node-exporter ClusterIP 10.96.34.73 9100/TCP 6d +default service/prometheus-operated ClusterIP None 9090/TCP 6d +kube-system service/kube-dns ClusterIP 10.96.0.10 53/UDP,53/TCP,9153/TCP 7d1h +kube-system service/prometheus-kube-prometheus-coredns ClusterIP None 9153/TCP 6d +kube-system service/prometheus-kube-prometheus-kube-controller-manager ClusterIP None 10257/TCP 6d +kube-system service/prometheus-kube-prometheus-kube-etcd ClusterIP None 2381/TCP 6d +kube-system service/prometheus-kube-prometheus-kube-proxy ClusterIP None 10249/TCP 6d +kube-system service/prometheus-kube-prometheus-kube-scheduler ClusterIP None 10259/TCP 6d +kube-system service/prometheus-kube-prometheus-kubelet ClusterIP None 10250/TCP,10255/TCP,4194/TCP 7d +mysql service/mysql ClusterIP None 3306/TCP 3m13s +todoapp service/todoapp-nodeport NodePort 10.96.226.11 80:30007/TCP 3m13s +todoapp service/todoapp-service ClusterIP 10.96.191.184 80/TCP 3m13s + +NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE +default daemonset.apps/prometheus-kube-prometheus-stack-prometheus-node-exporter 7 7 7 7 7 kubernetes.io/os=linux 6d +kube-system daemonset.apps/kindnet 7 7 7 7 7 kubernetes.io/os=linux 7d1h +kube-system daemonset.apps/kube-proxy 7 7 7 7 7 kubernetes.io/os=linux 7d1h + +NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE +default deployment.apps/grafana 1/1 1 1 6d +default deployment.apps/prometheus-kube-prometheus-operator 1/1 1 1 6d +default deployment.apps/prometheus-kube-prometheus-stack-grafana 1/1 1 1 6d +default deployment.apps/prometheus-kube-prometheus-stack-kube-state-metrics 1/1 1 1 6d +kube-system deployment.apps/coredns 2/2 2 2 7d1h +local-path-storage deployment.apps/local-path-provisioner 1/1 1 1 7d1h +todoapp deployment.apps/todoapp-todoapp 2/2 2 2 3m13s + +NAMESPACE NAME DESIRED CURRENT READY AGE +default replicaset.apps/grafana-8c8f844f 1 1 1 6d +default replicaset.apps/prometheus-kube-prometheus-operator-74c5cfdb84 1 1 1 6d +default replicaset.apps/prometheus-kube-prometheus-stack-grafana-74f59445f 1 1 1 6d +default replicaset.apps/prometheus-kube-prometheus-stack-kube-state-metrics-7858dcb5c4 1 1 1 6d +kube-system replicaset.apps/coredns-76f75df574 2 2 2 7d1h +local-path-storage replicaset.apps/local-path-provisioner-7577fdbbfb 1 1 1 7d1h +todoapp replicaset.apps/todoapp-todoapp-7cfbb4b546 2 2 2 3m13s + +NAMESPACE NAME READY AGE +default statefulset.apps/alertmanager-prometheus-kube-prometheus-alertmanager 1/1 6d +default statefulset.apps/prometheus-prometheus-kube-prometheus-prometheus 1/1 6d +mysql statefulset.apps/mysql 2/2 3m13s + +NAMESPACE NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE +todoapp horizontalpodautoscaler.autoscaling/todoapp-hpa Deployment/todoapp-todoapp /70%, /70% 2 5 2 3m13s + +NAMESPACE NAME DATA AGE +default configmap/grafana 1 6d +default configmap/kube-root-ca.crt 1 7d1h +default configmap/prometheus-kube-prometheus-alertmanager-overview 1 6d +default configmap/prometheus-kube-prometheus-apiserver 1 6d +default configmap/prometheus-kube-prometheus-cluster-total 1 6d +default configmap/prometheus-kube-prometheus-controller-manager 1 6d +default configmap/prometheus-kube-prometheus-etcd 1 6d +default configmap/prometheus-kube-prometheus-grafana-datasource 1 6d +default configmap/prometheus-kube-prometheus-grafana-overview 1 6d +default configmap/prometheus-kube-prometheus-k8s-coredns 1 6d +default configmap/prometheus-kube-prometheus-k8s-resources-cluster 1 6d +default configmap/prometheus-kube-prometheus-k8s-resources-multicluster 1 6d +default configmap/prometheus-kube-prometheus-k8s-resources-namespace 1 6d +default configmap/prometheus-kube-prometheus-k8s-resources-node 1 6d +default configmap/prometheus-kube-prometheus-k8s-resources-pod 1 6d +default configmap/prometheus-kube-prometheus-k8s-resources-workload 1 6d +default configmap/prometheus-kube-prometheus-k8s-resources-workloads-namespace 1 6d +default configmap/prometheus-kube-prometheus-kubelet 1 6d +default configmap/prometheus-kube-prometheus-namespace-by-pod 1 6d +default configmap/prometheus-kube-prometheus-namespace-by-workload 1 6d +default configmap/prometheus-kube-prometheus-node-cluster-rsrc-use 1 6d +default configmap/prometheus-kube-prometheus-node-rsrc-use 1 6d +default configmap/prometheus-kube-prometheus-nodes 1 6d +default configmap/prometheus-kube-prometheus-nodes-darwin 1 6d +default configmap/prometheus-kube-prometheus-persistentvolumesusage 1 6d +default configmap/prometheus-kube-prometheus-pod-total 1 6d +default configmap/prometheus-kube-prometheus-prometheus 1 6d +default configmap/prometheus-kube-prometheus-proxy 1 6d +default configmap/prometheus-kube-prometheus-scheduler 1 6d +default configmap/prometheus-kube-prometheus-stack-grafana 1 6d +default configmap/prometheus-kube-prometheus-stack-grafana-config-dashboards 1 6d +default configmap/prometheus-kube-prometheus-workload-total 1 6d +default configmap/prometheus-prometheus-kube-prometheus-prometheus-rulefiles-0 35 6d +kube-node-lease configmap/kube-root-ca.crt 1 7d1h +kube-public configmap/cluster-info 1 7d1h +kube-public configmap/kube-root-ca.crt 1 7d1h +kube-system configmap/coredns 1 7d1h +kube-system configmap/extension-apiserver-authentication 6 7d1h +kube-system configmap/kube-apiserver-legacy-service-account-token-tracking 1 7d1h +kube-system configmap/kube-proxy 2 7d1h +kube-system configmap/kube-root-ca.crt 1 7d1h +kube-system configmap/kubeadm-config 1 7d1h +kube-system configmap/kubelet-config 1 7d1h +local-path-storage configmap/kube-root-ca.crt 1 7d1h +local-path-storage configmap/local-path-config 4 7d1h +mysql configmap/kube-root-ca.crt 1 3m13s +mysql configmap/mysql 1 3m13s +todoapp configmap/kube-root-ca.crt 1 3m13s +todoapp configmap/todoapp-config 1 3m13s + +NAMESPACE NAME TYPE DATA AGE +default secret/alertmanager-prometheus-kube-prometheus-alertmanager Opaque 1 6d +default secret/alertmanager-prometheus-kube-prometheus-alertmanager-generated Opaque 1 6d +default secret/alertmanager-prometheus-kube-prometheus-alertmanager-tls-assets-0 Opaque 0 6d +default secret/alertmanager-prometheus-kube-prometheus-alertmanager-web-config Opaque 1 6d +default secret/grafana Opaque 3 6d +default secret/prometheus-kube-prometheus-admission Opaque 3 7d +default secret/prometheus-kube-prometheus-stack-grafana Opaque 3 6d +default secret/prometheus-prometheus-kube-prometheus-prometheus Opaque 1 6d +default secret/prometheus-prometheus-kube-prometheus-prometheus-tls-assets-0 Opaque 1 6d +default secret/prometheus-prometheus-kube-prometheus-prometheus-web-config Opaque 1 6d +default secret/sh.helm.release.v1.grafana.v1 helm.sh/release.v1 1 6d +default secret/sh.helm.release.v1.prometheus-kube-prometheus-stack.v1 helm.sh/release.v1 1 6d +default secret/sh.helm.release.v1.todoapp.v1 helm.sh/release.v1 1 3m13s +mysql secret/mysql-secrets Opaque 3 3m13s +todoapp secret/todoapp-secret Opaque 5 3m13s + +NAMESPACE NAME CLASS HOSTS ADDRESS PORTS AGE +todoapp ingress.networking.k8s.io/todoapp-ingress * 80 3m13s