Skip to content

Commit 49b99c3

Browse files
authored
Merge pull request #207 from eiximenis/master
v4 2023 - ejercicios
2 parents f4d1a72 + 2e6ae47 commit 49b99c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+959
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Comandos vistos
2+
3+
## Gestión de clústers
4+
5+
`kubectl config get-contexts` # ver contextos configurados
6+
`kubectl config use-context $context` # Conectarse al contexto indicado
7+
`kubectk config current-context` # Devuelve el contexto actual
8+
9+
Un contexto es una conexión contra un clúster especificado con unas credenciales determinadas. Los contextos se guardan en `~/.kube/config`
10+
11+
# Relacionados con pods
12+
13+
`kubectl run $pod_name --image $image_name` # Crea un pod que ejecuta un contenedor con la imagen indicada
14+
# `-it` enlaza terminal
15+
# `--rm` elimina el pod al terminar el contenedor
16+
# `--restart Never` No reinicia el conteneod si éste termina
17+
`kubectl run bb --imabge busybox -it --rm --restart Never`
18+
`kubectl port-forward $pod_name $local_port:$pod_port` # Crea un tunel TCP entre el puerto local y el puerto del pod indicado
19+
`kubectl get pods` # lista los pods
20+
`kubectl describe pod $pod_name` # Describe el pod mostrando varios datos en formato textual
21+
`kubectl delete pod $pod_name` # Elimina el pod. Para el contenedor automáticamente.
22+
`kubectl exec $pod_name -- $command` # Ejecuta un comando dentro del contenedor del pod indicado
23+
24+
A todos los comandos se les puede aplicar `-n $namespace` para que apliquen al namespace indicado (`default` por defecto)
25+
26+
# Relacionados con namespaces
27+
28+
`kubectl get ns` # Lista los namespaces
29+
30+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
labels:
5+
app: helloworld
6+
name: nginx
7+
spec:
8+
containers:
9+
- image: nginx
10+
name: nginx
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: helloworld1
5+
labels:
6+
app: helloworld
7+
spec:
8+
containers:
9+
- name: helloworld
10+
image: eiximenis/go-hello-world
11+
ports:
12+
- containerPort: 80
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: helloworld2
5+
labels:
6+
app: helloworld
7+
spec:
8+
containers:
9+
- name: helloworld
10+
image: eiximenis/go-hello-world
11+
ports:
12+
- containerPort: 80
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: helloworld
5+
spec:
6+
selector:
7+
app: helloworld
8+
ports:
9+
- port: 8080
10+
targetPort: 80
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
labels:
5+
run: nginx
6+
name: nginx
7+
spec:
8+
containers:
9+
- image: nginx
10+
name: nginx
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
labels:
5+
run: nginx
6+
name: nginx2
7+
spec:
8+
containers:
9+
- image: nginx
10+
name: nginx
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: apps/v1
2+
kind: ReplicaSet
3+
metadata:
4+
name: helloworld
5+
labels:
6+
app: helloworld-replicated
7+
spec:
8+
selector:
9+
matchLabels:
10+
app: helloworld
11+
replicas: 5
12+
template:
13+
metadata:
14+
labels:
15+
app: helloworld
16+
component: backend
17+
spec:
18+
containers:
19+
- name: helloworld
20+
image: eiximenis/go-hello-world
21+
ports:
22+
- containerPort: 80
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: mysql
5+
spec:
6+
containers:
7+
- name: mysql
8+
image: mysql
9+
env:
10+
- name: MYSQL_ROOT_PASSWORD
11+
value: "patata"
12+
- name: MYSQL_USER
13+
value: "wp"
14+
- name: MYSQL_PASSWORD
15+
value: "patata"
16+
- name: MYSQL_DATABASE
17+
value: "wp"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: wp
5+
spec:
6+
containers:
7+
- name: wp
8+
image: wordpress
9+
env:
10+
- name: WORDPRESS_DB_HOST
11+
value: "10.244.0.21"
12+
- name: WORDPRESS_DB_USER
13+
value: "wp"
14+
- name: WORDPRESS_DB_PASSWORD
15+
value: "patata"
16+
- name: WORDPRESS_DB_NAME
17+
value: "wp"

0 commit comments

Comments
 (0)