-
Notifications
You must be signed in to change notification settings - Fork 6
another helm exercise #128
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
base: master
Are you sure you want to change the base?
Changes from all commits
348e5f7
bf660cf
b7391e1
a1bfc12
48d9cd4
0e7cb53
0ca0da4
fedbcbc
d7c2e21
e70b401
555c996
3c0cdc6
2094e6a
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,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. |
| 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: wp-release | ||
| description: A Helm chart of Wordpress 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,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. | ||
|
|
||
| ############ | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # secret.yaml | ||
| apiVersion: v1 | ||
| kind: Secret | ||
| metadata: | ||
| name: wp-secrets | ||
| type: Opaque | ||
| data: | ||
| root-password: QzBudHI0c2VuNA== | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # wp-deploy.yaml | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
|
Contributor
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 should be a statefulset @manuelver : https://kubernetes.io/blog/2016/12/statefulset-run-scale-stateful-applications-in-kubernetes/ |
||
| 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 | ||
|
Contributor
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. I think the mount path should be the folder with the files that will be generated during the normal operation of the site, in specific the https://www.theistudio.com/where-are-wordpress-files-stored/#h-wordpress-file-locations
Contributor
Author
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. It would be more correct from wp-content to add the layout, theme and so on. But yes, from the html directory would be too much. |
||
| volumes: | ||
| - name: wordpress-persistent-storage | ||
| persistentVolumeClaim: | ||
| claimName: wp-pv-claim | ||
|
Contributor
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 disk should be a shared storage, like aws efs or Azure Fileshare. To be able to mount it in multiple pod replicas |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
| 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: wp-volume | ||
| description: A Helm chart of wp's volume 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,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". | ||
|
|
||
| ############ | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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: <your desired version> | ||
| repository: https://prefapp.github.io/prefapp-helm | ||
| ... | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. | ||
|
|
||
| ############ | ||
|
|
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.
The secret is not really encrypted, shouldn't be stored in the repo. You could use a service like aws parameter store, or sops to really encrypt the secret in the code.