Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Kubernetes Dashboard to v2.0.3 #1516

Merged
merged 1 commit into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-0.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
### Updated

- [#1479](https://github.com/epiphany-platform/epiphany/issues/1479) - Upgrade K8s to v1.18.6
- [#1510](https://github.com/epiphany-platform/epiphany/issues/1510) - Upgrade Kubernetes Dashboard to v2.0.3

### Fixed

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
---
- name: Upload and deploy Dashboard
# This file is meant to be also used by upgrade role

- name: Upload and deploy Kubernetes Dashboard
include_tasks: deployments/deploy-template.yml
vars:
file_name: kubernetes-dashboard.yml.j2
include_tasks: deployments/deploy-template.yml

- name: Check if kubernetes-dashboard is already deployed
environment:
KUBECONFIG: /etc/kubernetes/admin.conf
shell: |
kubectl get pods \
--namespace kubernetes-dashboard \
| grep -c -i dashboard
args:
executable: /bin/bash
register: dashboard_count
failed_when: dashboard_count.rc == 2
when:
- kubernetes_common.automation_designated_master == inventory_hostname

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
file: roles/kubernetes_master/files/coredns-deployment-patch.yml
name: coredns_deployment_patch

- name: Include tasks from deployments/patch-object.yml
include_tasks: deployments/patch-object.yml
- name: Include tasks from utils/patch-object.yml
include_tasks: utils/patch-object.yml
vars:
object:
kind: deployment
name: CoreDNS
name: coredns
namespace: kube-system
patch:
content: "{{ coredns_deployment_patch | to_json }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# Expected vars:
# - kind { deployment | daemonset }
# - selector
# - namespace

- name: "Get list of images for {{ kind }} using selector: {{ selector }}"
command: >-
kubectl get {{ kind }}
--selector {{ selector }}
-o=custom-columns='IMAGE:spec.template.spec.containers[*].image'
--namespace {{ namespace }}
--no-headers=true
register: kubectl_get_images
changed_when: false
environment:
KUBECONFIG: /etc/kubernetes/admin.conf

- name: Set list of images as fact
set_fact:
object_images: kubectl_get_images.stdout_lines
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
# Expected vars:
# - template_file
# - kind { deployment | daemonset }

- name: "Load {{ kind }}s from template file: {{ template_file }}"
set_fact:
deployments: >-
{{ lookup('template', './' + template_file) | from_yaml_all
| selectattr('kind', 'match', '(?i)' + kind) | list }}

- name: Get list of images from loaded template
set_fact:
template_images: >-
{{ deployments | json_query('[*].spec.template.spec.containers[*].image') | flatten }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
# Expected vars:
# - object:
# kind
# name
# namespace
# - patch:
# content
# type (optional)

- name: "Patch {{ object.kind }}: {{ object.name }}"
command: >-
kubectl patch {{ object.kind }} {{ object.name }}
--namespace {{ object.namespace }}
--type {{ patch.type | default('strategic') }}
--patch '{{ patch.content }}'
register: kubectl_patch
changed_when: not 'no change' in kubectl_patch.stdout
environment:
KUBECONFIG: /etc/kubernetes/admin.conf
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kubernetes-dashboard
namespace: kubernetes-dashboard
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down Expand Up @@ -188,7 +187,7 @@ spec:
spec:
containers:
- name: kubernetes-dashboard
image: {{ image_registry_address }}/kubernetesui/dashboard:v2.0.0-beta8
image: {{ image_registry_address }}/kubernetesui/dashboard:v2.0.3
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8443
Expand Down Expand Up @@ -225,6 +224,8 @@ spec:
- name: tmp-volume
emptyDir: {}
serviceAccountName: kubernetes-dashboard
nodeSelector:
"kubernetes.io/os": linux
# Comment the following tolerations if Dashboard must not be deployed on master
tolerations:
- key: node-role.kubernetes.io/master
Expand All @@ -236,41 +237,41 @@ kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-metrics-scraper
k8s-app: dashboard-metrics-scraper
name: dashboard-metrics-scraper
namespace: kubernetes-dashboard
spec:
ports:
- port: 8000
targetPort: 8000
selector:
k8s-app: kubernetes-metrics-scraper
k8s-app: dashboard-metrics-scraper

---

kind: Deployment
apiVersion: apps/v1
metadata:
labels:
k8s-app: kubernetes-metrics-scraper
name: kubernetes-metrics-scraper
k8s-app: dashboard-metrics-scraper
name: dashboard-metrics-scraper
namespace: kubernetes-dashboard
spec:
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
k8s-app: kubernetes-metrics-scraper
k8s-app: dashboard-metrics-scraper
template:
metadata:
labels:
k8s-app: kubernetes-metrics-scraper
k8s-app: dashboard-metrics-scraper
annotations:
seccomp.security.alpha.kubernetes.io/pod: 'runtime/default'
spec:
containers:
- name: kubernetes-metrics-scraper
image: {{ image_registry_address }}/kubernetesui/metrics-scraper:v1.0.1
- name: dashboard-metrics-scraper
image: {{ image_registry_address }}/kubernetesui/metrics-scraper:v1.0.4
ports:
- containerPort: 8000
protocol: TCP
Expand All @@ -290,10 +291,12 @@ spec:
runAsUser: 1001
runAsGroup: 2001
serviceAccountName: kubernetes-dashboard
nodeSelector:
"kubernetes.io/os": linux
# Comment the following tolerations if Dashboard must not be deployed on master
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
volumes:
- name: tmp-volume
emptyDir: {}
emptyDir: {}
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ https://get.helm.sh/helm-v3.2.0-linux-amd64.tar.gz
https://github.com/hashicorp/vault-helm/archive/v0.4.0.tar.gz

[images]
kubernetesui/dashboard:v2.0.0-beta8
kubernetesui/metrics-scraper:v1.0.1
kubernetesui/dashboard:v2.0.3
kubernetesui/metrics-scraper:v1.0.4
registry:2
hashicorp/vault-k8s:0.2.0
vault:1.3.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ https://get.helm.sh/helm-v3.2.0-linux-amd64.tar.gz
https://github.com/hashicorp/vault-helm/archive/v0.4.0.tar.gz

[images]
kubernetesui/dashboard:v2.0.0-beta8
kubernetesui/metrics-scraper:v1.0.1
kubernetesui/dashboard:v2.0.3
kubernetesui/metrics-scraper:v1.0.4
registry:2
hashicorp/vault-k8s:0.2.0
vault:1.3.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ https://get.helm.sh/helm-v3.2.0-linux-amd64.tar.gz
https://github.com/hashicorp/vault-helm/archive/v0.4.0.tar.gz

[images]
kubernetesui/dashboard:v2.0.0-beta8
kubernetesui/metrics-scraper:v1.0.1
kubernetesui/dashboard:v2.0.3
kubernetesui/metrics-scraper:v1.0.4
registry:2
hashicorp/vault-k8s:0.2.0
vault:1.3.2
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
- name: Check if upgrade is needed
block:
- name: k8s/master | Include tasks from utils/get-images-from-deployment-template
include_role:
name: kubernetes_master
tasks_from: utils/get-images-from-deployment-template # sets template_images
vars:
kind: deployment
template_file: kubernetes-dashboard.yml.j2

- name: k8s/master | Include tasks from utils/get-deployment-images
include_role:
name: kubernetes_master
tasks_from: utils/get-deployment-images # sets object_images
vars:
kind: deployment
selector: k8s-app=kubernetes-dashboard
namespace: kubernetes-dashboard

- name: k8s/master | Check if Kubernetes Dashboard should be upgraded
set_fact:
upgrade_k8s_dashboard: >-
{{ (template_images | difference(object_images) | count > 0) | ternary(true, false) }}

- name: Upgrade dashboard
when: upgrade_k8s_dashboard
block:
- name: k8s/master | Delete kubernetes-dashboard namespace
command: >-
kubectl delete ns kubernetes-dashboard
environment:
KUBECONFIG: /etc/kubernetes/admin.conf

# Deploy new version of kubernetes-dashboard
- name: k8s/master | Apply Kubernetes Dashboard
include_role:
name: kubernetes_master
tasks_from: apply-dashboard

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
- name: k8s/master0 | Reconfigure keycloak application
include_tasks: reconfigure-auth-service-app.yml

- name: k8s/master0 | Upgrade kubernetes-dashboard
include_tasks: upgrade-kubernetes-dashboard.yml

- name: k8s/master0 | Drain master in preparation for maintenance
include_tasks: utils/drain.yml

Expand Down Expand Up @@ -115,6 +112,11 @@
- name: k8s/master0 | Upgrade CNI plugin pod
include_tasks: upgrade-cni-plugin-pod.yml

- name: k8s/master0 | Upgrade Kubernetes Dashboard
include_tasks: upgrade-k8s-dashboard.yml
when:
- upgrade_to_final_version

- name: k8s/master0 | Backup kubeadm-config.yml
include_tasks: backup-kubeadm-config.yml

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ specification:
file_name: rabbitmq-3.7.10.tar
- name: "apacheignite/ignite:2.5.0"
file_name: ignite-2.5.0.tar
- name: "kubernetesui/dashboard:v2.0.0-beta8"
file_name: dashboard-v2.0.0-beta8.tar
- name: "kubernetesui/metrics-scraper:v1.0.1"
file_name: metrics-scraper-v1.0.1.tar
- name: "kubernetesui/dashboard:v2.0.3"
file_name: dashboard-v2.0.3.tar
- name: "kubernetesui/metrics-scraper:v1.0.4"
file_name: metrics-scraper-v1.0.4.tar
- name: "vault:1.3.2"
file_name: vault-1.3.2.tar
- name: "hashicorp/vault-k8s:0.2.0"
Expand Down