项目作者: sinlead

项目描述 :
kubectl plugin for Drone CI
高级语言: Shell
项目地址: git://github.com/sinlead/drone-kubectl.git
创建时间: 2019-01-23T03:32:09Z
项目社区:https://github.com/sinlead/drone-kubectl

开源协议:GNU General Public License v3.0

下载


drone-kubectl

This Drone plugin allows you to use kubectl without messing around with the authentication

Usage

  1. # drone 1.0 syntax
  2. kind: pipeline
  3. name: deploy
  4. steps:
  5. - name: deploy
  6. image: sinlead/drone-kubectl
  7. settings:
  8. kubernetes_server:
  9. from_secret: k8s_server
  10. kubernetes_cert:
  11. from_secret: k8s_cert
  12. kubernetes_token:
  13. from_secret: k8s_token
  14. commands:
  15. - kubectl create -f job_foo.yaml
  16. - kubectl wait --for=condition=complete -f job_foo.yaml

How to get the credentials

First, you need to have a service account with proper privileges and service-account-token.

You can find out your server URL which looks like https://xxx.xxx.xxx.xxx by the command:

  1. kubectl config view -o jsonpath='{range .clusters[*]}{.name}{"\t"}{.cluster.server}{"\n"}{end}'

If the service account is deploy, you would have a secret named deploy-token-xxxx (xxxx is some random characters).
You can get your token and certificate by the following commands:

cert:

  1. kubectl get secret deploy-token-xxxx -o jsonpath='{.data.ca\.crt}' && echo

token:

  1. kubectl get secret deploy-token-xxxx -o jsonpath='{.data.token}' | base64 --decode && echo

Special thanks

Inspired by drone-kubernetes.