juanesech
7/12/2017 - 3:42 PM

Kubectl commands (Tambien en dropbox)

Kubectl commands (Tambien en dropbox)

#Configurar proyecto
gcloud config set project nutresa-165613
gcloud config set project nutresa-lab
gcloud config set project nutresa-prod
gcloud config set project prisma-yosimar

#Subir imagen a container registry
gcloud docker -- push gcr.io/nutresa-165613/prisma_backend

#Configurar Zona
gcloud config set compute/zone us-central1-f

#Crear cluster
gcloud container --project "nutresa-lab" clusters create "prisma-3020-frontend-clu-lab" --zone "us-central1-f" --machine-type "custom-1-2048" --num-nodes "1" --network "nutresa-lab" --subnetwork "laboratorio"
gcloud container --project "nutresa-lab" clusters create "prisma-3020-backend-clu-lab-test" --zone "us-central1-f" --machine-type "custom-1-2048" --num-nodes "1" --network "nutresa-lab" --subnetwork "laboratorio" --tags="all"

gcloud container --project "nutresa-prod" clusters create "prisma-3020-frontend-clu-prod" --zone "us-central1-f" --machine-type "custom-1-2048" --num-nodes "1" --network "nutresa-prod" --subnetwork "produccion" --tags="all"
gcloud container --project "nutresa-prod" clusters create "prisma-3020-backend-clu-prod" --zone "us-central1-f" --machine-type "custom-1-2048" --num-nodes "1" --network "nutresa-prod" --subnetwork "produccion" --tags="all"

#Obtener credenciales de cluster
gcloud container clusters get-credentials ${GCLOUD_CLUSTER}

gcloud container clusters get-credentials prisma-3020-backend-clu-prod
gcloud container clusters get-credentials prisma-3020-backend-clu-lab
gcloud container clusters get-credentials prisma-3020-backend-clu

gcloud container clusters get-credentials prisma-3020-frontend-clu-prod
gcloud container clusters get-credentials prisma-3020-frontend-clu-lab
gcloud container clusters get-credentials prisma-3020-frontend-clu

#Listar instancias (VM)
gcloud compute instances list

#Desplegar Docker image en cluster  kubernetes
kubectl run prisma-3020-frontend-clu-prod --image=gcr.io/nutresa-165613/prisma_frontend:173 --env ARTIFACT_REPO=Prisma
kubectl run prisma-3020-backend-clu-prod --image=gcr.io/nutresa-165613/prisma_backend:241 --port 8089 --env ARTIFACT_REPO=Prisma

kubectl run prisma-3020-frontend-clu-lab --image=gcr.io/nutresa-165613/prisma_frontend:173 --port 80 --env ARTIFACT_REPO=Prisma_lab
kubectl run prisma-3020-backend-clu-lab --image=gcr.io/nutresa-165613/prisma_backend:173 --port 8089 --env ARTIFACT_REPO=Prisma_lab

kubectl run prisma-3020-frontend-clu --image=gcr.io/nutresa-165613/prisma_frontend:127 --port 80 --env ARTIFACT_REPO=Prisma_dev
kubectl run prisma-3020-backend-clu --image=gcr.io/nutresa-165613/prisma_backend:173 --port 8089 --env ARTIFACT_REPO=Prisma_dev

#Actualizar imagen de docker
kubectl set image deployment/prisma-cluster prisma-cluster=gcr.io/nutresa-165613/prisma_backend:1
kubectl set image deployment/prisma-cluster prisma-cluster=gcr.io/nutresa-165613/prisma_backend:1
kubectl set image deployment/prisma-3020-frontend-clu prisma-3020-frontend-clu=gcr.io/nutresa-165613/prisma_frontend:184

#Exponer
kubectl expose deployment prisma-3020-frontend-clu-lab --type=LoadBalancer --name=prisma-3020-frontend-clu-lab
kubectl expose deployment prisma-3020-backend-clu-lab --type=LoadBalancer --name=prisma-3020-backend-clu-lab
kubectl expose deployment prisma-3020-backend-clu-prod --type=LoadBalancer --name=prisma-3020-backend-clu-prod
kubectl expose deployment prisma-3020-frontend-clu-prod --type=LoadBalancer --name=prisma-3020-frontend-clu-prod
kubectl expose deployment prisma-3020-backend-clu-prod --type=LoadBalancer --name=prisma-3020-backend-clu-prod

#Listar pods
kubectl get pods

#Generar contenedor
docker run -i -t -d --name=prisma_backend --hostname=prisma --restart=always --privileged -p 8089:8089 -p 2230:22 prisma-back /bin/bash

#Pull a imagen en gcloud
gcloud docker -- pull gcr.io/nutresa-165613/liquibase

#
docker run -i -t -d --name=prisma_backend --hostname=prisma --restart=always --privileged -p 8089:8089 -p 2230:22 prisma_back /bin/bash
docker exec -ti prisma_backend /bin/bash