changes to use new cluster
This commit is contained in:
@@ -5,7 +5,7 @@ def registry = "registry.c.test-chamber-13.lan"
|
|||||||
def alpineImage = "${registry}/library/alpine"
|
def alpineImage = "${registry}/library/alpine"
|
||||||
def alpineTag = "latest"
|
def alpineTag = "latest"
|
||||||
|
|
||||||
def kubectlCreds = "rancher-admin-token"
|
def kubectlCreds = "k8s-dl-automation-access"
|
||||||
def nordCreds = "nordvpn-login-creds"
|
def nordCreds = "nordvpn-login-creds"
|
||||||
|
|
||||||
def nordURLs = [
|
def nordURLs = [
|
||||||
@@ -32,9 +32,9 @@ def kubeNamespace = "dl-automation"
|
|||||||
def kubeSecret = "openvpn"
|
def kubeSecret = "openvpn"
|
||||||
|
|
||||||
podTemplate(
|
podTemplate(
|
||||||
label: label,
|
label: label,
|
||||||
name: "pipeline-worker",
|
name: "pipeline-worker",
|
||||||
yaml: """---
|
yaml: """---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Pod
|
kind: Pod
|
||||||
metadata:
|
metadata:
|
||||||
@@ -49,55 +49,55 @@ spec:
|
|||||||
- /bin/sh
|
- /bin/sh
|
||||||
""",
|
""",
|
||||||
) {
|
) {
|
||||||
node (label) {
|
node (label) {
|
||||||
def workspace = pwd()
|
def workspace = pwd()
|
||||||
|
|
||||||
stage ("Update Secret") {
|
stage ("Update Secret") {
|
||||||
container ("alpine") {
|
container ("alpine") {
|
||||||
sh """
|
sh """
|
||||||
apk add --no-cache curl jq sed
|
apk add --no-cache curl jq sed
|
||||||
KUBE_VERSION="\$(curl --location --silent https://dl.k8s.io/release/stable.txt)"
|
KUBE_VERSION="\$(curl --location --silent https://dl.k8s.io/release/stable.txt)"
|
||||||
curl \
|
curl \
|
||||||
--location \
|
--location \
|
||||||
--silent \
|
--silent \
|
||||||
--output /usr/local/bin/kubectl \
|
--output /usr/local/bin/kubectl \
|
||||||
"https://dl.k8s.io/release/\${KUBE_VERSION}/bin/linux/amd64/kubectl"
|
"https://dl.k8s.io/release/\${KUBE_VERSION}/bin/linux/amd64/kubectl"
|
||||||
chmod +x /usr/local/bin/kubectl
|
chmod +x /usr/local/bin/kubectl
|
||||||
"""
|
"""
|
||||||
|
|
||||||
withCredentials([string(
|
withCredentials([string(
|
||||||
credentialsId: nordCreds,
|
credentialsId: nordCreds,
|
||||||
variable: "NORD_CREDS",
|
variable: "NORD_CREDS",
|
||||||
)]) {
|
)]) {
|
||||||
|
|
||||||
withKubeConfig([
|
withKubeConfig([
|
||||||
credentialsId: kubectlCreds,
|
credentialsId: kubectlCreds,
|
||||||
serverUrl: "https://rancher.test-chamber-13.lan/k8s/clusters/c-mc9cq",
|
serverUrl: "https://kubernetes.test-chamber-13.lan:6443",
|
||||||
namespace: "webservers"
|
namespace: "webservers"
|
||||||
]) {
|
]) {
|
||||||
sh """
|
sh """
|
||||||
# Get OpenVPN Config
|
# Get OpenVPN Config
|
||||||
OPENVPN_CONFIG="\$(
|
OPENVPN_CONFIG="\$(
|
||||||
curl \
|
curl \
|
||||||
--silent \
|
--silent \
|
||||||
--location \
|
--location \
|
||||||
--fail \
|
--fail \
|
||||||
"https://downloads.nordcdn.com/configs/files/ovpn_tcp/servers/\$(
|
"https://downloads.nordcdn.com/configs/files/ovpn_tcp/servers/\$(
|
||||||
curl \
|
curl \
|
||||||
--silent \
|
--silent \
|
||||||
--location \
|
--location \
|
||||||
--fail \
|
--fail \
|
||||||
'""" + nordURL + """' \
|
'""" + nordURL + """' \
|
||||||
| jq \
|
| jq \
|
||||||
--raw-output \
|
--raw-output \
|
||||||
'[.[] | select(.technologies[] | .identifier == "openvpn_tcp")][0] | .hostname' \
|
'[.[] | select(.technologies[] | .identifier == "openvpn_tcp")][0] | .hostname' \
|
||||||
).tcp.ovpn" \
|
).tcp.ovpn" \
|
||||||
| sed \
|
| sed \
|
||||||
--regexp-extended \
|
--regexp-extended \
|
||||||
--expression='s/auth-user-pass/auth-user-pass \\/etc\\/openvpn\\/client\\/openvpn-credentials.txt/' \
|
--expression='s/auth-user-pass/auth-user-pass \\/etc\\/openvpn\\/client\\/openvpn-credentials.txt/' \
|
||||||
| base64 -w 0
|
| base64 -w 0
|
||||||
)"
|
)"
|
||||||
printf '%s\n' \
|
printf '%s\n' \
|
||||||
"apiVersion: v1" \
|
"apiVersion: v1" \
|
||||||
"kind: Secret" \
|
"kind: Secret" \
|
||||||
"metadata:" \
|
"metadata:" \
|
||||||
@@ -107,14 +107,14 @@ spec:
|
|||||||
" openvpn-credentials.txt: \${NORD_CREDS}" \
|
" openvpn-credentials.txt: \${NORD_CREDS}" \
|
||||||
" us5766.nordvpn.com.tcp.ovpn: \${OPENVPN_CONFIG}" > /tmp/openvpn-secret.kubectl
|
" us5766.nordvpn.com.tcp.ovpn: \${OPENVPN_CONFIG}" > /tmp/openvpn-secret.kubectl
|
||||||
|
|
||||||
kubectl apply --namespace """ + kubeNamespace + """ -f /tmp/openvpn-secret.kubectl
|
kubectl apply --namespace """ + kubeNamespace + """ -f /tmp/openvpn-secret.kubectl
|
||||||
for i in \$(kubectl get pods --namespace """ + kubeNamespace + """ --selector app="deluge" -o name); do
|
for i in \$(kubectl get pods --namespace """ + kubeNamespace + """ --selector app="deluge" -o name); do
|
||||||
kubectl delete --namespace """ + kubeNamespace + """ \${i}
|
kubectl delete --namespace """ + kubeNamespace + """ \${i}
|
||||||
done
|
done
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user