diff --git "a/cursos/helm/00_solucions/99_other_wp/Manuel_Vergara-helm-M\303\263dulo2.pdf" "b/cursos/helm/00_solucions/99_other_wp/Manuel_Vergara-helm-M\303\263dulo2.pdf" new file mode 100644 index 00000000..2d7119a7 Binary files /dev/null and "b/cursos/helm/00_solucions/99_other_wp/Manuel_Vergara-helm-M\303\263dulo2.pdf" differ diff --git a/cursos/helm/00_solucions/99_other_wp/README.md b/cursos/helm/00_solucions/99_other_wp/README.md new file mode 100644 index 00000000..c311d34a --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/README.md @@ -0,0 +1,5 @@ +# Índice de los archivos de las prácticas + +- En la carpeta [wordpress](./wordpress/) están los manifiestos de prueba. +- En la carpeta [actividade-1-charts-helm](./actividade-1-charts-helm/) está la primera prueba de release sin los objetos built-in de helm. +- En la carpeta [actividade-2-charts-helm](./actividade-2-charts-helm/) incluye objetos built-in de helm. diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/.helmignore b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/.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/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/Chart.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/Chart.yaml new file mode 100644 index 00000000..f665e803 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: wp-release +description: A Helm chart of Wordpress for Kubernetes +type: application +version: 0.1.0 +appVersion: "1.16.0" diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/NOTES.txt b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/NOTES.txt new file mode 100644 index 00000000..a19deb51 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/NOTES.txt @@ -0,0 +1,13 @@ +############ + +La instalación de la release wp-release se compone en: +- Despliegue y servicio de BBDD +- Despliegue y servicio de WP +- Configmap +- Secrets +- Ingress + +Es necesaria la instalación de la release wp-volume para darle persistencia a la bbdd mysql y a la configuración de wordpress. + +############ + diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/bbdd-deploy.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/bbdd-deploy.yaml new file mode 100644 index 00000000..3623be74 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/bbdd-deploy.yaml @@ -0,0 +1,43 @@ +# bbdd-deploy.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: deploy-wp-bbdd + labels: + app: "wp-mysql" + tipo: "practica" +spec: + replicas: 1 + selector: + matchLabels: + app: wp-mysql + template: # a partir de aquí definimos o pod + metadata: + labels: + app: wp-mysql + spec: + containers: + - name: wp-mysql + image: mysql:8.0 + env: + - name: "MYSQL_ROOT_PASSWORD" + valueFrom: + secretKeyRef: + name: wp-secrets + key: root-password + - name: "MYSQL_DATABASE" + valueFrom: + configMapKeyRef: + name: "wp-config" + key: "MYSQL_DATABASE" + ports: + - containerPort: 3306 + volumeMounts: + - name: wp-db-persistent-storage + mountPath: /var/lib/mysql + volumes: + - name: wp-db-persistent-storage + persistentVolumeClaim: + claimName: wp-db-pv-claim + + diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/bbdd-service.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/bbdd-service.yaml new file mode 100644 index 00000000..6dbd00fd --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/bbdd-service.yaml @@ -0,0 +1,12 @@ +# bbdd-service.yaml +kind: Service +apiVersion: v1 +metadata: + name: servicio-wp-bbdd +spec: + selector: + app: wp-mysql + ports: # esta é a parte de especificación propia + - protocol: TCP + port: 3306 + targetPort: 3306 diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/configmap.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/configmap.yaml new file mode 100644 index 00000000..29bc00c0 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/configmap.yaml @@ -0,0 +1,11 @@ +# configmap.yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: wp-config + labels: + tipo: "practica" +data: + MYSQL_HOST: servicio-wp-bbdd + MYSQL_USER: "root" + MYSQL_DATABASE: "wp-db" diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/ingress.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/ingress.yaml new file mode 100644 index 00000000..c2810ce9 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/ingress.yaml @@ -0,0 +1,20 @@ +# ingress.yaml +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: wp-ingress + annotations: + nginx.ingress.kubernetes.io/rewrite-target: "/" + nginx.ingress.kubernetes.io/ssl-redirect: "false" + +spec: + rules: + - http: + paths: + - pathType: Prefix + path: /v1 + backend: + service: + name: servicio-wp + port: + number: 8080 diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/secret.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/secret.yaml new file mode 100644 index 00000000..3bc32fec --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/secret.yaml @@ -0,0 +1,8 @@ +# secret.yaml +apiVersion: v1 +kind: Secret +metadata: + name: wp-secrets +type: Opaque +data: + root-password: QzBudHI0c2VuNA== diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/wp-deploy.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/wp-deploy.yaml new file mode 100644 index 00000000..f2f42da7 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/wp-deploy.yaml @@ -0,0 +1,39 @@ +# wp-deploy.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: deploy-wp + labels: + app: "deploy-wp" + tipo: "practica" +spec: + replicas: 1 + selector: + matchLabels: + app: deploy-wp + template: + metadata: + labels: + app: deploy-wp + spec: + containers: + - name: deploy-wp + image: wordpress:6.1 + env: + - name: "MYSQL_PASSWORD" + valueFrom: + secretKeyRef: + name: wp-secrets + key: root-password + envFrom: + - configMapRef: + name: wp-config + ports: + - containerPort: 8080 + volumeMounts: + - name: wordpress-persistent-storage + mountPath: /var/www/html + volumes: + - name: wordpress-persistent-storage + persistentVolumeClaim: + claimName: wp-pv-claim diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/wp-service.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/wp-service.yaml new file mode 100644 index 00000000..57b5016d --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/templates/wp-service.yaml @@ -0,0 +1,12 @@ +# wp-service.yaml +kind: Service +apiVersion: v1 +metadata: + name: servicio-wp +spec: + selector: + app: deploy-wp + ports: + - protocol: TCP + port: 8080 + targetPort: 80 diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/values.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/values.yaml new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-release/values.yaml @@ -0,0 +1 @@ + diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-volume/.helmignore b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-volume/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-volume/.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/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-volume/Chart.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-volume/Chart.yaml new file mode 100644 index 00000000..04df18d2 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-volume/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: wp-volume +description: A Helm chart of wp's volume for Kubernetes +type: application +version: 0.1.0 +appVersion: "1.16.0" diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-volume/templates/NOTES.txt b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-volume/templates/NOTES.txt new file mode 100644 index 00000000..f1643d33 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-volume/templates/NOTES.txt @@ -0,0 +1,10 @@ +############ + +La instalación de la release wp-volume se compone en: +- Volumen para bbdd mysql de la release "wp-release" +- Volumen para el CMS Wordpress de la release "wp-release" + +Esta release no debería borrarse y en todo caso debe tener backups periódicos, ya que contiene los datos que deben ser persistentes de la release "wp-release". + +############ + diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-volume/templates/bbdd-volume.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-volume/templates/bbdd-volume.yaml new file mode 100644 index 00000000..ad84ee79 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-volume/templates/bbdd-volume.yaml @@ -0,0 +1,13 @@ +#bbdd-volume.yaml +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: wp-db-pv-claim + labels: + app: deploy-wp-bbdd +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 2Gi diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-volume/templates/wp-volume.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-volume/templates/wp-volume.yaml new file mode 100644 index 00000000..9cc491fd --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-volume/templates/wp-volume.yaml @@ -0,0 +1,13 @@ +# wp-volume.yaml +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: wp-pv-claim + labels: + app: deploy-wp +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 2Gi diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-volume/values.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-volume/values.yaml new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-1-charts-helm/wp-volume/values.yaml @@ -0,0 +1 @@ + diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/README.md b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/README.md new file mode 100644 index 00000000..4fc86573 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/README.md @@ -0,0 +1,24 @@ +# ¿Cómo se ha construido está release? + +Siguiendo el tutorial de [formación de Helm](https://prefapp.github.io/formacion/cursos/helm/#/) desde la plantilla de release creada en la [actividad 1](../actividade-1-charts-helm/) se han añadido [valores y su interpolación](https://prefapp.github.io/formacion/cursos/helm/#/./02_helm_charts/01_valores_y_su_interpolacion). + +Después se ha añadido el repo del microframework de [Prefapp Helm](https://github.com/prefapp/prefapp-helm) para implementar Charts modulares. + +```shell +helm repo add prefapp-helm https://prefapp.github.io/prefapp-helm +helm repo update +``` + +Y se ha incluído la dependencia en el fichero Chart.yaml. + +```yaml +# Chart.yaml + +... +dependencies: + # ... your other dependencies + - name: prefapp-helm + version: + repository: https://prefapp.github.io/prefapp-helm +... +``` diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/.helmignore b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/.helmignore new file mode 100644 index 00000000..aa3052b0 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/.helmignore @@ -0,0 +1,45 @@ +# 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/ + + +# Según prefapp-helm ignorar también +# + + +templates/_renders_cert_issuer.yaml +templates/_stash.yaml + +tests/ + +README.md + +*.sh + +docs/ + +a.yml + +*.tgz + +oldtests/ diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/Chart.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/Chart.yaml new file mode 100644 index 00000000..13bc33b7 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/Chart.yaml @@ -0,0 +1,14 @@ +apiVersion: v2 +name: wp +description: A Helm chart of Wordpress for Kubernetes +type: application +version: 0.1.0 +appVersion: "1.16.0" + + +# Artefactos de prefapp-helm + +#dependencies: +# - name: prefapp-helm +# version: 0.4.1 +# repository: https://prefapp.github.io/prefapp-helm \ No newline at end of file diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/NOTES.txt b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/NOTES.txt new file mode 100644 index 00000000..a19deb51 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/NOTES.txt @@ -0,0 +1,13 @@ +############ + +La instalación de la release wp-release se compone en: +- Despliegue y servicio de BBDD +- Despliegue y servicio de WP +- Configmap +- Secrets +- Ingress + +Es necesaria la instalación de la release wp-volume para darle persistencia a la bbdd mysql y a la configuración de wordpress. + +############ + diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/bbdd-deploy.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/bbdd-deploy.yaml new file mode 100644 index 00000000..03a3e9dc --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/bbdd-deploy.yaml @@ -0,0 +1,54 @@ +# bbdd-deploy.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: deploy-{{ .Release.Name }}-bbdd + namespace: {{ .Values.namespace }} + labels: + app: {{ .Release.Name }}-mysql + tipo: "practica" +spec: + replicas: {{ if eq (toString .replicas) "0" }} {{ .replicas }} {{ else }} {{ (default 1 .replicas) }} {{ end }} + selector: + matchLabels: + app: {{ .Release.Name }}-mysql + template: # a partir de aquí definimos o pod + metadata: + labels: + app: {{ .Release.Name }}-mysql + spec: + containers: + - name: {{ .Release.Name }}-mysql + image: {{ .Values.images.mysql }} + env: + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Release.Name }}-secret + key: root-password + - name: MYSQL_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Release.Name }}-secret + key: user-password + - name: MYSQL_DATABASE + valueFrom: + configMapKeyRef: + name: {{ .Release.Name }}-configmap + key: "MYSQL_DATABASE" + - name: MYSQL_USER + valueFrom: + configMapKeyRef: + name: {{ .Release.Name }}-configmap + key: MYSQL_USER + ports: + - containerPort: 3306 + volumeMounts: + - name: wp-db-persistent-storage + mountPath: /var/lib/mysql + volumes: + - name: wp-db-persistent-storage + persistentVolumeClaim: + claimName: wp-db-pv-claim + + diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/bbdd-service.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/bbdd-service.yaml new file mode 100644 index 00000000..e8cde3da --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/bbdd-service.yaml @@ -0,0 +1,13 @@ +# bbdd-service.yaml +kind: Service +apiVersion: v1 +metadata: + name: servicio-{{ .Release.Name }}-bbdd + namespace: {{ .Values.namespace }} +spec: + selector: + app: {{ .Release.Name }}-mysql + ports: # esta é a parte de especificación propia + - protocol: TCP + port: 3306 + targetPort: 3306 diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/configmap.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/configmap.yaml new file mode 100644 index 00000000..e3981d42 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/configmap.yaml @@ -0,0 +1,12 @@ +# configmap.yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-configmap + namespace: "{{ .Values.namespace }}" + labels: + tipo: "practica" +data: + MYSQL_HOST: servicio-{{ .Release.Name }}-bbdd + MYSQL_USER: {{ .Values.mysql.DB_USER }} + MYSQL_DATABASE: {{ .Values.mysql.DB_BBDD }} diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/ingress.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/ingress.yaml new file mode 100644 index 00000000..952a7e77 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/ingress.yaml @@ -0,0 +1,20 @@ +# ingress.yaml +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: wp-ingress + namespace: {{ .Values.namespace }} + annotations: + nginx.ingress.kubernetes.io/rewrite-target: "/" + nginx.ingress.kubernetes.io/ssl-redirect: "false" +spec: + rules: + - http: + paths: + - pathType: Prefix + path: / + backend: + service: + name: servicio-{{ .Release.Name }} + port: + number: 80 diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/secret.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/secret.yaml new file mode 100644 index 00000000..487bab84 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/secret.yaml @@ -0,0 +1,10 @@ +# secret.yaml +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Release.Name }}-secret + namespace: "{{ .Values.namespace }}" +type: Opaque +data: + root-password: QzBudHI0c2VuNA== + user-password: VXNlckMwbnRyNHNlbjQK \ No newline at end of file diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/wp-deploy.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/wp-deploy.yaml new file mode 100644 index 00000000..d997b2d2 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/wp-deploy.yaml @@ -0,0 +1,55 @@ +# wp-deploy.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: deploy-{{ .Release.Name }} + namespace: {{ .Values.namespace }} + labels: + app: deploy-{{ .Release.Name }} + tipo: "practica" +spec: + replicas: {{ if eq (toString .replicas) "0" }} {{ .replicas }} {{ else }} {{ (default 1 .replicas) }} {{ end }} + selector: + matchLabels: + app: deploy-{{ .Release.Name }} + template: + metadata: + labels: + app: deploy-{{ .Release.Name }} + spec: + containers: + - name: deploy-{{ .Release.Name }} + image: {{ .Values.images.wp }} + env: + - name: WORDPRESS_DB_HOST + valueFrom: + configMapKeyRef: + name: {{ .Release.Name }}-configmap + key: MYSQL_HOST + - name: WORDPRESS_DB_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Release.Name }}-secret + key: user-password + - name: WORDPRESS_DB_NAME + valueFrom: + configMapKeyRef: + name: {{ .Release.Name }}-configmap + key: "MYSQL_DATABASE" + - name: WORDPRESS_DB_USER + valueFrom: + configMapKeyRef: + name: {{ .Release.Name }}-configmap + key: MYSQL_USER + envFrom: + - configMapRef: + name: {{ .Release.Name }}-configmap + ports: + - containerPort: 8080 + volumeMounts: + - name: wordpress-persistent-storage + mountPath: /var/www/html + volumes: + - name: wordpress-persistent-storage + persistentVolumeClaim: + claimName: wp-pv-claim diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/wp-service.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/wp-service.yaml new file mode 100644 index 00000000..ce9baccf --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/templates/wp-service.yaml @@ -0,0 +1,13 @@ +# wp-service.yaml +kind: Service +apiVersion: v1 +metadata: + name: servicio-{{ .Release.Name }} + namespace: {{ .Values.namespace }} +spec: + selector: + app: deploy-{{ .Release.Name }} + ports: + - protocol: TCP + port: 80 + targetPort: 80 diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/values.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/values.yaml new file mode 100644 index 00000000..33e787db --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-release/values.yaml @@ -0,0 +1,10 @@ +namespace: "wp-release2" + +images: + mysql: "mysql:8.0" + wp: wordpress:6.1 + +mysql: + DB_BBDD: "wp-db" + DB_USER: "user-wp" + diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-volume/.helmignore b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-volume/.helmignore new file mode 100644 index 00000000..aa3052b0 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-volume/.helmignore @@ -0,0 +1,45 @@ +# 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/ + + +# Según prefapp-helm ignorar también +# + + +templates/_renders_cert_issuer.yaml +templates/_stash.yaml + +tests/ + +README.md + +*.sh + +docs/ + +a.yml + +*.tgz + +oldtests/ diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-volume/Chart.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-volume/Chart.yaml new file mode 100644 index 00000000..04df18d2 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-volume/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: wp-volume +description: A Helm chart of wp's volume for Kubernetes +type: application +version: 0.1.0 +appVersion: "1.16.0" diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-volume/templates/NOTES.txt b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-volume/templates/NOTES.txt new file mode 100644 index 00000000..f1643d33 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-volume/templates/NOTES.txt @@ -0,0 +1,10 @@ +############ + +La instalación de la release wp-volume se compone en: +- Volumen para bbdd mysql de la release "wp-release" +- Volumen para el CMS Wordpress de la release "wp-release" + +Esta release no debería borrarse y en todo caso debe tener backups periódicos, ya que contiene los datos que deben ser persistentes de la release "wp-release". + +############ + diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-volume/templates/bbdd-volume.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-volume/templates/bbdd-volume.yaml new file mode 100644 index 00000000..65b850c6 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-volume/templates/bbdd-volume.yaml @@ -0,0 +1,15 @@ +#bbdd-volume.yaml +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: wp-db-pv-claim + namespace: "wp-release2" + labels: + app: deploy-wp-bbdd +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 2Gi + diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-volume/templates/wp-volume.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-volume/templates/wp-volume.yaml new file mode 100644 index 00000000..39a8fc56 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-volume/templates/wp-volume.yaml @@ -0,0 +1,14 @@ +# wp-volume.yaml +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: wp-pv-claim + namespace: "wp-release2" + labels: + app: deploy-wp +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 2Gi diff --git a/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-volume/values.yaml b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-volume/values.yaml new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/actividade-2-charts-helm/wp-volume/values.yaml @@ -0,0 +1 @@ + diff --git a/cursos/helm/00_solucions/99_other_wp/wordpress/bbdd-deploy.yaml b/cursos/helm/00_solucions/99_other_wp/wordpress/bbdd-deploy.yaml new file mode 100644 index 00000000..c80c86d4 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/wordpress/bbdd-deploy.yaml @@ -0,0 +1,29 @@ +# bbdd-deploy.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: deploy-wp-bbdd + labels: + app: "wp-mysql" + tipo: "practica" +spec: + replicas: 1 + selector: + matchLabels: + app: wp-mysql + template: # a partir de aquí definimos o pod + metadata: + labels: + app: wp-mysql + spec: + containers: + - name: wp-mysql + image: mysql:8.0 + env: + - name: "MYSQL_ROOT_PASSWORD" + valueFrom: + secretKeyRef: + name: wp-secrets + key: root-password + ports: + - containerPort: 3306 diff --git a/cursos/helm/00_solucions/99_other_wp/wordpress/bbdd-service.yaml b/cursos/helm/00_solucions/99_other_wp/wordpress/bbdd-service.yaml new file mode 100644 index 00000000..6dbd00fd --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/wordpress/bbdd-service.yaml @@ -0,0 +1,12 @@ +# bbdd-service.yaml +kind: Service +apiVersion: v1 +metadata: + name: servicio-wp-bbdd +spec: + selector: + app: wp-mysql + ports: # esta é a parte de especificación propia + - protocol: TCP + port: 3306 + targetPort: 3306 diff --git a/cursos/helm/00_solucions/99_other_wp/wordpress/configmap.yaml b/cursos/helm/00_solucions/99_other_wp/wordpress/configmap.yaml new file mode 100644 index 00000000..29bc00c0 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/wordpress/configmap.yaml @@ -0,0 +1,11 @@ +# configmap.yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: wp-config + labels: + tipo: "practica" +data: + MYSQL_HOST: servicio-wp-bbdd + MYSQL_USER: "root" + MYSQL_DATABASE: "wp-db" diff --git a/cursos/helm/00_solucions/99_other_wp/wordpress/ingress.yaml b/cursos/helm/00_solucions/99_other_wp/wordpress/ingress.yaml new file mode 100644 index 00000000..d9243503 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/wordpress/ingress.yaml @@ -0,0 +1,19 @@ +# ingress.yaml +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: wp-ingress + annotations: + nginx.ingress.kubernetes.io/rewrite-target: "/" + nginx.ingress.kubernetes.io/ssl-redirect: "false" +spec: + rules: + - http: + paths: + - pathType: Prefix + path: / + backend: + service: + name: servicio-wp + port: + number: 80 diff --git a/cursos/helm/00_solucions/99_other_wp/wordpress/secret.yaml b/cursos/helm/00_solucions/99_other_wp/wordpress/secret.yaml new file mode 100644 index 00000000..3bc32fec --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/wordpress/secret.yaml @@ -0,0 +1,8 @@ +# secret.yaml +apiVersion: v1 +kind: Secret +metadata: + name: wp-secrets +type: Opaque +data: + root-password: QzBudHI0c2VuNA== diff --git a/cursos/helm/00_solucions/99_other_wp/wordpress/wp-deploy.yaml b/cursos/helm/00_solucions/99_other_wp/wordpress/wp-deploy.yaml new file mode 100644 index 00000000..d5714746 --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/wordpress/wp-deploy.yaml @@ -0,0 +1,32 @@ +# wp-deploy.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: deploy-wp + labels: + app: "deploy-wp" + tipo: "practica" +spec: + replicas: 1 + selector: + matchLabels: + app: deploy-wp + template: + metadata: + labels: + app: deploy-wp + spec: + containers: + - name: deploy-wp + image: wordpress:6.1 + env: + - name: "MYSQL_PASSWORD" + valueFrom: + secretKeyRef: + name: wp-secrets + key: root-password + envFrom: + - configMapRef: + name: wp-config + ports: + - containerPort: 8080 diff --git a/cursos/helm/00_solucions/99_other_wp/wordpress/wp-service.yaml b/cursos/helm/00_solucions/99_other_wp/wordpress/wp-service.yaml new file mode 100644 index 00000000..fd29594e --- /dev/null +++ b/cursos/helm/00_solucions/99_other_wp/wordpress/wp-service.yaml @@ -0,0 +1,12 @@ +# wp-service.yaml +kind: Service +apiVersion: v1 +metadata: + name: servicio-wp +spec: + selector: + app: deploy-wp + ports: + - protocol: TCP + port: 80 + targetPort: 80