Skip to content

Instantly share code, notes, and snippets.

@theguuholi
Created April 1, 2021 14:17
Show Gist options
  • Save theguuholi/44df09dae2ff1ef43a11a7ae3a1bc245 to your computer and use it in GitHub Desktop.
Save theguuholi/44df09dae2ff1ef43a11a7ae3a1bc245 to your computer and use it in GitHub Desktop.

Principais Comandos

  • kubectl #client k8s
    • cluster-info

    • create #comando imperativo para criar objetos

      • secret #tipo do objeto
        • generic #tipo de segurança
          • #nome da chave para ser referencia em configurações
            • —from-literal #vamos adicionar a chave por comando
              • key=valor #valor de configuracao
                • ex: kubectl create secret generic pgpassword —from-literal PGPASSWORD=postgres
      • serviceaccount #cria uma conta de serviço
        • —namespace
          • kube-system #em um kube-system namespace
            • tiller #com o nome tiller
              • kubectl create serviceaccount --namespace kube-system tiller
      • clusterrolebinding
        • tiller-cluster-rule
          • —clusterrole=cluster-admin
            • —serviceaccount=kube-system:tiller

              • #cria um clusterrolebinding com o papel de **'cluster-admin'**assinado para uma conta de serviço tiller
              • kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:ti

              ller

    • apply #muda a configuração do cluster

      • -f #especifica um arquivo de configuração
        • <nome_arquivo> #caminho do arquivo de configuração
          • ex: kubectl apply -f store-pod.yaml
    • get #retorna informações sobre um objeto

      • pods
        • ex: kubectl get pods
      • namespaces
      • services
        • ex: kubectl get services
      • deployments
        • ex: kubectl get deployments
      • storageclass
        • ex: kubectl get storage class
      • secrets
        • ex: kubectl get secrets
      • pv #mostar os persistence volumes
      • pvc #o que esta disponível
      • -o wide
    • set #atualiza uma propriedade de um dos objetos dentro do cluster

      • image
        • / =
          • ex: kubectl set image deployment/store-deployment store=store:v2
    • delete #deleta objeto de configuração

      • -f
        • <arquivo de configuração>
          • ex: kubectl delete -f store-pod.yaml
    • describe

      • deployment
      • pod
      • storageclass
      • service
    • logs

      • - ex: - similar: docker logs
    • exec

      • -it
        • comando:
          • ex:
          • similar: docker exec -it <c_id> sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment