Skip to content

Commit 77a4b83

Browse files
committed
K8S-69 upgrades cumulative improvement
1 parent fba78bc commit 77a4b83

File tree

2 files changed

+52
-11
lines changed

2 files changed

+52
-11
lines changed

addons/upgrade.jps

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ onInstall:
3333
version: ${settings.version}
3434
- script: |
3535
var message = "Kubernetes Cluster has been successfuly upgraded! **Current version:** ${settings.version}. \n\nNo other upgrades are available.";
36-
if ("${this.avail}") message += "\n\n**Next version:** ${this.avail}. \nPress \"Upgrade\" button to start the upgrade process.";
36+
if ("${settings.avail}") message += "\n\n**Next version:** ${this.avail}. \nPress \"Upgrade\" button to start the upgrade process.";
3737
return {result:"info", message:message};
3838

3939
actions:
@@ -44,7 +44,7 @@ actions:
4444
chmod +x /usr/local/sbin/wait-deployment.sh
4545
kubectl get daemonset weave-net -n kube-system && {
4646
kubectl apply -f ${baseUrl}/addons/weave-pack.yaml;
47-
kubectl -n kube-system wait --for=condition=Ready pod -l name=weave-net --timeout=-1s; }
47+
kubectl -n kube-system wait --for=condition=Ready pod -l name=weave-net --timeout=-1s; } ||:
4848
- cmd[${nodes.k8sm.master.id}]: |-
4949
kubectl get daemonset traefik-ingress-controller -n kube-system &>/dev/null && echo "traefik" ||:
5050
kubectl get deployment nginx-ingress-controller -n ingress-nginx &>/dev/null && echo "nginx" ||:
@@ -83,25 +83,57 @@ actions:
8383
kubectl apply -f ${baseUrl}/addons/metrics-server/resource-reader.yaml
8484
wait-deployment.sh metrics-server kube-system 1 720
8585
- cmd[${nodes.k8sm.master.id}]: |-
86-
kubectl get deploy kubernetes-dashboard -n kubernetes-dashboard && {
86+
kubectl get deployment kubernetes-dashboard -n kubernetes-dashboard && {
8787
kubectl delete ns kubernetes-dashboard;
88-
kubectl apply -f ${baseUrl}/addons/kubernetes-dashboard-beta.yaml;
89-
kubectl apply -f ${baseUrl}/addons/ingress/${globals.ingress-dir}/dashboard-ingress-beta.yaml; }
88+
for i in {1..5}; do sleep 5; echo "Attempt ${i}/5: "; kubectl apply -f ${baseUrl}/addons/kubernetes-dashboard-beta.yaml && break; done;
89+
kubectl apply -f ${baseUrl}/addons/ingress/${globals.ingress-dir}/dashboard-ingress-beta.yaml; } ||:
90+
- cmd[${nodes.k8sm.master.id}]: |-
91+
kubectl get deployment hello-kubernetes && {
92+
kubectl apply -f ${baseUrl}/addons/helloworld.yaml;
93+
kubectl apply -f ${baseUrl}/addons/ingress/${globals.ingress-dir}/helloworld-ingress.yaml; } ||:
9094
- cmd[${nodes.k8sm.master.id}]: |-
9195
helm init --upgrade --service-account tiller
9296
helm repo update
9397
wait-deployment.sh tiller-deploy kube-system 1 720
98+
- cmd[${nodes.k8sm.master.id}]: |-
99+
kubectl get secret --namespace kubernetes-monitoring monitoring-grafana && {
100+
helm upgrade monitoring-prometheus stable/prometheus --set server.prefixURL=/prometheus --set server.baseURL=/prometheus ;
101+
wait-deployment.sh monitoring-prometheus-server kubernetes-monitoring 1 720;
102+
helm fetch stable/grafana --untar;
103+
helm upgrade monitoring-grafana --set 'grafana\.ini'.server.root_url=${env.url}grafana -f ${baseUrl}/addons/monitoring/jelastic-values.yaml grafana/. ;
104+
wait-deployment.sh monitoring-grafana kubernetes-monitoring 1 720;
105+
kubectl apply -f ${baseUrl}/addons/monitoring/${globals.ingress-dir}/prometheus-ingress.yaml;
106+
kubectl apply -f ${baseUrl}/addons/monitoring/${globals.ingress-dir}/alert-ingress.yaml;
107+
kubectl apply -f ${baseUrl}/addons/monitoring/${globals.ingress-dir}/grafana-ingress.yaml; } ||:
108+
- cmd[${nodes.k8sm.master.id}]: echo $(kubectl get NetworkPolicy,PodSecurityPolicy,DaemonSet,Deployment,ReplicaSet --all-namespaces -o 'jsonpath={range .items[*]}{.metadata.annotations.kubectl\.kubernetes\.io/last-applied-configuration}{"\n"}{end}' | grep '"apiVersion":"extensions/v1beta1"')
109+
- setGlobals:
110+
k8s_deprecated_ext: ${response.out}
111+
- if ('${globals.k8s_deprecated_ext}'):
112+
return:
113+
type: warning
114+
message: Deprecated Kubernetes Extensions API found! Please review installed components prior to Kubernetes 1.16+ cluster upgrade.
115+
- cmd[${nodes.k8sm.master.id}]: echo $(kubectl get DaemonSet,Deployment,StatefulSet,ReplicaSet --all-namespaces -o 'jsonpath={range .items[*]}{.metadata.annotations.kubectl\.kubernetes\.io/last-applied-configuration}{"\n"}{end}' | grep '"apiVersion":"apps/v1beta')
116+
- setGlobals:
117+
k8s_deprecated_app: ${response.out}
118+
- if ('${globals.k8s_deprecated_app}'):
119+
return:
120+
type: warning
121+
message: Deprecated Kubernetes Apps API found! Please review installed components prior to Kubernetes 1.16+ cluster upgrade.
94122

95123
upgrade-masters:
96124
- env.control.RedeployContainers:
97125
nodeId: ${this.id}
98126
tag: ${this.version}
99127
skipReinstall: true
100128
- cmd[${this.id}]: |-
101-
wget -nv https://github.com/weaveworks/weave/releases/download/v2.5.2/weave -O /usr/bin/weave
102-
chmod +x /usr/bin/weave
129+
kubectl get daemonset weave-net -n kube-system && {
130+
wget -nv https://github.com/weaveworks/weave/releases/download/v2.5.2/weave -O /usr/bin/weave;
131+
chmod +x /usr/bin/weave; } ||:
103132
wget -nv ${baseUrl}/scripts/wait-deployment.sh -O /usr/local/sbin/wait-deployment.sh
104133
chmod +x /usr/local/sbin/wait-deployment.sh
134+
[ -f "/root/wait-deployment.sh" ] && {
135+
rm -f /root/wait-deployment.sh;
136+
ln -s /usr/local/sbin/wait-deployment.sh /root/wait-deployment.sh; } ||:
105137
while true; do kubectl get nodes --no-headers | grep -qv '\sReady\s' || break ; done
106138
sleep 5
107139
- if (${this.master}):

manifest.jps

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,12 +498,20 @@ addons:
498498
resp = jelastic.env.control.GetContainerNodeTags(envName, session, nodeId);
499499
if (resp.result != 0) return resp;
500500
var tags = resp.object;
501-
var upgrades = [];
502-
var sig_version = ["v1.15.6"];
503-
for (var i = 0; i < sig_version.length; i++) if (sig_version[i] > version) upgrades.push(sig_version[i]);
504501
tags.sort();
502+
var upgrades = [];
503+
var check_version = version;
504+
var major_version = version.substr(0, version.lastIndexOf("."));
505+
for (var i = 0; i < tags.length; i++) {
506+
var major_tag = tags[i].substr(0, tags[i].lastIndexOf("."));
507+
if (major_tag > major_version) {
508+
check_version = tags[i];
509+
upgrades.push(check_version);
510+
major_version = major_tag;
511+
}
512+
}
505513
var last_version = tags.pop();
506-
if (last_version > version) upgrades.push(last_version);
514+
if (last_version > check_version) upgrades.push(last_version);
507515
var message = "Current version " + version + " is the latest. No upgrades are available.";
508516
if (upgrades.length) {
509517
upgrades.sort();
@@ -528,6 +536,7 @@ addons:
528536
envName: ${env.envName}
529537
settings:
530538
version: ${this.next}
539+
avail: ${this.avail}
531540

532541
- id: gitlab-k8s-addon
533542
type: update

0 commit comments

Comments
 (0)