// Aula 16 - Labels https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ # vim teste-prod-deployment.yaml # teste-prod-deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: teste-prod labels: ver: "1" app: teste env: prod spec: replicas: 2 selector: matchLabels: app: teste template: metadata: labels: app: teste spec: containers: - name: teste-prod image: gcr.io/kuar-demo/kuard-amd64:green ports: - containerPort: 80 # kubectl apply -f teste-prod-deployment.yaml # vim teste-test-deployment.yaml # teste-test-deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: teste-test labels: ver: "2" app: teste env: test spec: replicas: 2 selector: matchLabels: app: teste template: metadata: labels: app: teste spec: containers: - name: teste-test image: gcr.io/kuar-demo/kuard-amd64:green ports: - containerPort: 80 # kubectl apply -f teste-test-deployment.yaml # vim teste2-prod-deployment.yaml # teste2-prod-deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: teste2-prod labels: ver: "2" app: teste2 env: prod spec: replicas: 2 selector: matchLabels: app: teste2 template: metadata: labels: app: teste2 spec: containers: - name: teste2 image: gcr.io/kuar-demo/kuard-amd64:green ports: - containerPort: 80 # kubectl apply -f teste2-prod-deployment.yaml # vim teste2-staging-deployment.yaml # teste2-staging-deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: teste2-staging labels: ver: "2" app: teste2 env: staging spec: replicas: 2 selector: matchLabels: app: teste2 template: metadata: labels: app: teste2 spec: containers: - name: teste2 image: gcr.io/kuar-demo/kuard-amd64:green ports: - containerPort: 80 # kubectl apply -f teste2-staging-deployment.yaml # kubectl get deployments --show-labels # kubectl label deployments teste-test "canary=true" # kubectl get deployments --show-labels # kubectl get deployments -L canary # kubectl label deployments teste-test "canary-" # kubectl get pods --show-labels # kubectl get pods --selector="app=teste" # kubectl get pods --selector="app in (teste, teste2)" # kubectl get pods --selector="canary" # kubectl get deployments --selector='!canary' # kubectl get pods -l 'app=teste,!canary' # kubectl delete deployments --selector='app=teste' # kubectl get pods --show-labels # kubectl delete deployments --all