Kubernetes: Usando Kubernetes na IBM Cloud: Difference between revisions
No edit summary |
|||
Line 3: | Line 3: | ||
Os exemplos do curso estão no GitHub https://github.com/IBM/container-service-getting-started-wt | Os exemplos do curso estão no GitHub https://github.com/IBM/container-service-getting-started-wt | ||
= Pré-requisitos = | |||
== Instalando os pré-requisitos == | |||
No MacOS | No MacOS | ||
Line 16: | Line 15: | ||
brew install docker | brew install docker | ||
== Login na IBM Cloud == | |||
ibmcloud login | ibmcloud login | ||
Line 24: | Line 23: | ||
ibmcloud login -sso | ibmcloud login -sso | ||
== Install the IBM Cloud plug-ins== | |||
Install the IBM Cloud Kubernetes Service plug-in to create Kubernetes clusters and manage worker nodes by installing the IBM Cloud Kubernetes Service plug-in: | Install the IBM Cloud Kubernetes Service plug-in to create Kubernetes clusters and manage worker nodes by installing the IBM Cloud Kubernetes Service plug-in: | ||
Line 38: | Line 37: | ||
: container-service/kubernetes-service 0.1.593 | : container-service/kubernetes-service 0.1.593 | ||
== Provisionando um Cluster na IBM Cloud == | |||
Vá no endereço https://console.bluemix.net/catalog/ e localize a entrada '''IBM Cloud Kubernetes Service'''. | Vá no endereço https://console.bluemix.net/catalog/ e localize a entrada '''IBM Cloud Kubernetes Service'''. | ||
= Deploy da sua Primeira aplicação no IBM Cloud= | |||
== Push da imagem para o IBM Cloud Container Registry == | |||
Clonando os exemplos do Github | Clonando os exemplos do Github | ||
Line 85: | Line 84: | ||
Anotar o ip público do '''worker'''. | Anotar o ip público do '''worker'''. | ||
== Deploy da aplicação == | |||
Execute o comando e defina as variáveis de ambiente | Execute o comando e defina as variáveis de ambiente | ||
Line 107: | Line 106: | ||
kubectl expose deployment/hello-world --type="NodePort" --port=8080 | kubectl expose deployment/hello-world --type="NodePort" --port=8080 | ||
=== Para achar a porta === | |||
kubectl describe service <name-of-deployment> | kubectl describe service <name-of-deployment> | ||
=== Para remover o Deployment === | |||
kubectl delete deployment hello-world. | kubectl delete deployment hello-world. | ||
=== Para remover o Service === | |||
kubectl delete service hello-world. | kubectl delete service hello-world. |
Revision as of 20:55, 27 October 2018
Existe um curso sobre Kubernetes na IBM Cloud, o link é o seguinte https://courses.cognitiveclass.ai/
Os exemplos do curso estão no GitHub https://github.com/IBM/container-service-getting-started-wt
Pré-requisitos
Instalando os pré-requisitos
No MacOS
brew install kubectl brew cask install ibm-cloud-cli brew install cfssl brew install docker
Login na IBM Cloud
ibmcloud login
Para FederatedID (Ex. Funcionário IBM)
ibmcloud login -sso
Install the IBM Cloud plug-ins
Install the IBM Cloud Kubernetes Service plug-in to create Kubernetes clusters and manage worker nodes by installing the IBM Cloud Kubernetes Service plug-in:
ibmcloud plugin install container-service -r Bluemix ibmcloud plugin install container-registry -r Bluemix
Listando plug-ins instalados...
ibmcloud plugin list
- Nome do Plug-in Versão
- container-service/kubernetes-service 0.1.593
Provisionando um Cluster na IBM Cloud
Vá no endereço https://console.bluemix.net/catalog/ e localize a entrada IBM Cloud Kubernetes Service.
Deploy da sua Primeira aplicação no IBM Cloud
Push da imagem para o IBM Cloud Container Registry
Clonando os exemplos do Github
mkdir Curso git clone https://github.com/IBM/container-service-getting-started-wt.git
Login na IBM Cloud
bx login --sso
Login na IBM Cloud Container Registry.
bx cr login
Criando uma namespace
bx cr namespace-add <my_namespace>
Criando uma docker image
docker build --tag registry.ng.bluemix.net/<my_namespace>/hello-world:1 .
Verificando a imagem
docker images
Fazendo o push da image
docker push registry.ng.bluemix.net/<my_namespace>/hello-world:1
Verifique que o cluster está pronto pra uso
bx cs clusters # verificar se o estado está normal bx cs workers <yourclustername> # Verifica se os workers estão no estado "Normal" com o status "Ready"
Anotar o ip público do worker.
Deploy da aplicação
Execute o comando e defina as variáveis de ambiente
bx cs cluster-config <yourclustername>
Exemplo no Mac
export KUBECONFIG=/Users/<user_name>/.bluemix/plugins/container-service/clusters/pr_firm_cluster/kube-config-prod-par02-pr_firm_cluster.yml
Iniciando a aplicação
kubectl run hello-world --image=registry.ng.bluemix.net/<my_namespace>/hello-world:1
Verifique o status pelo comando
kubectl get pods
Quando o status estiver como Running, execute
kubectl expose deployment/hello-world --type="NodePort" --port=8080
Para achar a porta
kubectl describe service <name-of-deployment>
Para remover o Deployment
kubectl delete deployment hello-world.
Para remover o Service
kubectl delete service hello-world.