You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 2022/es/Days/day61.md
+40-41Lines changed: 40 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,21 @@
1
-
## Kubernetes & Multiple Environments
1
+
## Kubernetes y entornos múltiples
2
2
3
-
So far during this section on Infrastructure as code, we have looked at deploying virtual machines albeit to VirtualBox but the premise is the same really as we define in code what we want our virtual machine to look like and then we deploy. The same for Docker containers and in this session, we are going to take a look at how Terraform can be used to interact with resources supported by Kubernetes.
3
+
Hasta ahora, durante esta sección sobre infraestructura como código, hemos visto cómo implementar máquinas virtuales, aunque sea en VirtualBox, pero la premisa es la misma: definimos en código cómo queremos que se vea nuestra máquina virtual y luego la implementamos. Lo mismo ocurre con los contenedores de Docker, y en esta sesión vamos a ver cómo Terraform se puede utilizar para interactuar con los recursos admitidos por Kubernetes.
4
4
5
-
I have been using Terraform to deploy my Kubernetes clusters for demo purposes across the 3 main cloud providers and you can find the repository[tf_k8deploy](https://github.com/MichaelCade/tf_k8deploy)
5
+
He estado utilizando Terraform para implementar mis clústeres de Kubernetes con fines de demostración en los 3 principales proveedores de nube, y puedes encontrar el repositorio[tf_k8deploy](https://github.com/MichaelCade/tf_k8deploy)
6
6
7
-
However you can also use Terraform to interact with objects within the Kubernetes cluster, this could be using the [Kubernetes provider](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs)or it could be using the [Helm provider](https://registry.terraform.io/providers/hashicorp/helm/latest)to manage your chart deployments.
7
+
Sin embargo, también puedes usar Terraform para interactuar con objetos dentro del clúster de Kubernetes. Esto podría ser utilizando el [proveedor de Kubernetes](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs)o el [ proveedor de Helm](https://registry.terraform.io/providers/hashicorp/helm/latest)para gestionar las implementaciones de tus gráficos.
8
8
9
-
Now we could use `kubectl` as we have shown in previous sections. But there are some benefits to using Terraform in your Kubernetes environment.
9
+
Ahora podríamos usar `kubectl`, como hemos mostrado en secciones anteriores. Pero hay algunos beneficios al usar Terraform en tu entorno de Kubernetes:
10
10
11
-
- Unified workflow - if you have used Terraform to deploy your clusters, you could use the same workflow and tool to deploy within your Kubernetes clusters
11
+
- Flujo de trabajo unificado: si has utilizado Terraform para implementar tus clústeres, puedes utilizar el mismo flujo de trabajo y herramienta para implementar dentro de tus clústeres de Kubernetes.
12
+
- Gestión del ciclo de vida: Terraform no es solo una herramienta de aprovisionamiento, también permite realizar cambios, actualizaciones y eliminaciones.
12
13
13
-
- Lifecycle management - Terraform is not just a provisioning tool, it's going to enable change, updates and deletions.
14
+
## Demostración simple de Kubernetes
14
15
15
-
### Simple Kubernetes Demo
16
+
Similar a la demostración que creamos en la última sesión, ahora podemos implementar NGINX en nuestro clúster de Kubernetes. Aquí usaré minikube nuevamente con fines de demostración. Creamos nuestro archivo `Kubernetes.tf` y puedes encontrarlo en la [carpeta](2022/Days/IaC/Kubernetes/Kubernetes.tf)
16
17
17
-
Much like the demo we created in the last session, we can now deploy nginx into our Kubernetes cluster, I will be using minikube here again for demo purposes. We create our Kubernetes.tf file and you can find this in the [folder](2022/Days/IaC/Kubernetes/Kubernetes.tf)
18
-
19
-
In that file we are going to define our Kubernetes provider, we are going to point to our kubeconfig file, create a namespace called nginx, and then we will create a deployment which contains 2 replicas and finally service.
18
+
En ese archivo, vamos a definir nuestro proveedor de Kubernetes, vamos a apuntar a nuestro archivo `kubeconfig`, crear un espacio de nombres llamado "nginx" y luego crearemos una implementación que contiene 2 réplicas y, finalmente, un servicio.
The first thing we have to do in our new project folder is run the `terraform init` command.
86
+
Lo primero que tenemos que hacer en nuestra nueva carpeta de proyecto es ejecutar el comando `terraform init`.
88
87
89
88

90
89
91
-
And then before we run the`terraform apply` command, let me show you that we have no namespaces.
90
+
Y antes de ejecutar el comando`terraform apply`, permíteme mostrarte que no tenemos espacios de nombres.
92
91
93
92

94
93
95
-
When we run our apply command this is going to create those 3 new resources, namespace, deployment and service within our Kubernetes cluster.
94
+
Cuando ejecutamos nuestro comando apply, esto creará esos 3 nuevos recursos: el espacio de nombres, la implementación y el servicio dentro de nuestro clúster de Kubernetes.
96
95
97
96

98
97
99
-
We can now take a look at the deployed resources within our cluster.
98
+
Ahora podemos echar un vistazo a los recursos implementados en nuestro clúster.
100
99
101
100

102
101
103
-
Now because we are using minikube as you will have seen in the previous section this has its limitations when we try and play with the docker networking for ingress. But if we simply issue the`kubectl port-forward -n nginx svc/nginx 30201:80`command and open a browser to `http://localhost:30201/` we should see our NGINX page.
102
+
Ahora, debido a que estamos usando minikube, como habrás visto en la sección anterior, tiene sus limitaciones cuando intentamos trabajar con la red de Docker para el ingreso. Pero si simplemente emitimos el comando`kubectl port-forward -n nginx svc/nginx 30201:80`y abrimos un navegador en `http://localhost:30201/`, deberíamos ver nuestra página de NGINX.
104
103
105
104

106
105
107
-
If you want to try out more detailed demos with Terraform and Kubernetes then the [HashiCorp Learn site](https://learn.hashicorp.com/tutorials/terraform/kubernetes-provider) is fantastic to run through.
108
-
109
-
### Multiple Environments
106
+
Si quieres probar demos más detalladas con Terraform y Kubernetes, la [web de HashiCorp Learn](https://learn.hashicorp.com/tutorials/terraform/kubernetes-provider) es fantástico para seguir.
110
107
111
-
If we wanted to take any of the demos we have run through but wanted to now have specific production, staging and development environments looking the same and leveraging this code there are two approaches to achieve this with Terraform
108
+
### Entornos múltiples
112
109
113
-
-`terraform workspaces` - multiple named sections within a single backend
110
+
Si quisiéramos tomar cualquiera de las demos que hemos visto pero ahora queremos tener entornos de producción, de preparación y de desarrollo específicos que se vean iguales y aprovechen este código, hay dos enfoques para lograrlo con Terraform:
-`terraform workspaces`: secciones con nombre múltiples dentro de un único backend.
113
+
- Estructura de archivos: el diseño de directorios proporciona separación y los módulos proporcionan reutilización.
116
114
117
-
Each of the above does have its pros and cons though.
115
+
Cada uno de los enfoques tiene sus pros y sus contras.
118
116
119
117
### terraform workspaces
120
118
121
119
Pros
122
120
123
-
- Easy to get started
124
-
- Convenient terraform.workspace expression
125
-
- Minimises code duplication
121
+
-Fácil de comenzar.
122
+
-Expresión terraform.workspace conveniente.
123
+
-Minimiza la duplicación de código.
126
124
127
-
Cons
125
+
Contras
128
126
129
-
-Prone to human error (we were trying to eliminate this by using TF)
130
-
-State stored within the same backend
131
-
-Codebase doesn't unambiguously show deployment configurations.
127
+
-Propenso a errores humanos (estábamos tratando de eliminar esto al usar TF).
128
+
-El estado se almacena en el mismo backend.
129
+
-El código base no muestra de manera inequívoca las configuraciones de implementación.
132
130
133
-
### File Structure
131
+
### Estructura de archivos
134
132
135
133
Pros
136
134
137
-
-Isolation of backends
138
-
-improved security
139
-
-decreased potential for human error
140
-
-Codebase fully represents deployed state
135
+
-Aislamiento de backends:
136
+
-Mejora de la seguridad.
137
+
-Disminución del potencial de errores humanos.
138
+
-El código base representa completamente el estado implementado.
141
139
142
-
Cons
140
+
Contras
143
141
144
-
-Multiple terraform apply required to provision environments
145
-
-More code duplication, but can be minimised with modules.
142
+
-Se requiere la ejecución de varios terraform apply para aprovisionar los entornos.
143
+
-Mayor duplicación de código, pero se puede minimizar con módulos.
146
144
147
-
## Resources
145
+
## Recursos
148
146
149
-
I have listed a lot of resources down below and I think this topic has been covered so many times out there, If you have additional resources be sure to raise a PR with your resources and I will be happy to review and add them to the list.
147
+
He enumerado muchos recursos a continuación y creo que este tema se ha cubierto muchas veces, así que si tienes recursos adicionales, asegúrate de enviar una solicitud de extracción (PR) con tus recursos y estaré encantado de revisarlos y agregarlos a la lista.
150
148
151
149
-[What is Infrastructure as Code? Difference of Infrastructure as Code Tools](https://www.youtube.com/watch?v=POPP2WTJ8es)
0 commit comments