forked from komljen/drone-kubectl-helm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·36 lines (29 loc) · 1 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# Inspired by https://github.com/honestbee/drone-kubernetes/blob/master/update.sh
if [[ ! -z ${KUBERNETES_TOKEN} ]]; then
KUBERNETES_TOKEN=$KUBERNETES_TOKEN
fi
if [[ ! -z ${KUBERNETES_SERVER} ]]; then
KUBERNETES_SERVER=$KUBERNETES_SERVER
fi
if [[ ! -z ${KUBERNETES_CERT} ]]; then
KUBERNETES_CERT=${KUBERNETES_CERT}
fi
kubectl config set-credentials default --token=${KUBERNETES_TOKEN}
if [[ ! -z ${KUBERNETES_CERT} ]]; then
echo ${KUBERNETES_CERT} | base64 -d >ca.crt
kubectl config set-cluster default --server=${KUBERNETES_SERVER} --certificate-authority=ca.crt
else
echo "WARNING: Using insecure connection to cluster"
kubectl config set-cluster default --server=${KUBERNETES_SERVER} --insecure-skip-tls-verify=true
fi
kubectl config set-context default --cluster=default --user=default
kubectl config use-context default
# Run kubectl command
if [[ ! -z ${PLUGIN_KUBECTL} ]]; then
kubectl ${PLUGIN_KUBECTL}
fi
# Run helm command
if [[ ! -z ${PLUGIN_HELM} ]]; then
helm ${PLUGIN_HELM}
fi