Commit a75998b5 by Diego Lima

treinamento

1 parent 24388219
apiVersion: v1 apiVersion: v1
kind: Namespace kind: Namespace
metadata: metadata:
name: treinamento-k8s name: diegolima
...@@ -8,7 +8,7 @@ metadata: ...@@ -8,7 +8,7 @@ metadata:
spec: spec:
containers: containers:
- name: web - name: web
image: nginx image: nginx:latest
ports: ports:
- name: web - name: web
containerPort: 80 containerPort: 80
......
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
namespace: treinamento-k8s
labels:
role: webserver
spec:
replicas: 2
selector:
matchLabels:
role: webserver
template:
metadata:
labels:
role: webserver
spec:
containers:
- name: web
image: diegolima/treinamento-k8s:2
ports:
- containerPort: 80
\ No newline at end of file
apiVersion: v1
kind: Service
metadata:
name: webserver
namespace: treinamento-k8s
spec:
selector:
role: webserver
ports:
- protocol: TCP
port: 80
targetPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: webserver-lb
namespace: treinamento-k8s
spec:
selector:
role: webserver
ports:
- protocol: TCP
port: 80
targetPort: 80
type: LoadBalancer
\ No newline at end of file
# Configuracao do cliente kubectl para acessar o cluster no google cloud
$ docker run --name gcloud -v $PWD:/mnt -ti google/cloud-sdk bash
$ gcloud auth login
$ gcloud config set project treinamento-k8s
$ gcloud container clusters get-credentials cluster --region us-central1-c
-----------------------
# Kubernetes
$ kubectl get nodes
$ kubectl get namespaces
$ kubectl create namespace diegolima
$ kubectl get namespaces
$ kubectl delete namespace diegolima
$ kubectl apply -f /mnt/namespace.yaml
$ kubectl -n diegolima get pods
apiVersion: v1
kind: Namespace
metadata:
name: diegolima
---
apiVersion: v1
kind: Pod
metadata:
name: nginx
namespace: diegolima
labels:
role: webserver
spec:
containers:
- name: web
image: nginx:latest
ports:
- name: web
containerPort: 80
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: webserver-lb
namespace: diegolima
spec:
selector:
role: webserver
ports:
- protocol: TCP
port: 80
targetPort: 80
type: LoadBalancer
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!