From 0a9b72b07a5fa5b92b8fad2454eaf93a126a4c80 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Wed, 26 Jun 2024 22:26:46 +0200 Subject: [PATCH] chore(kubernetes-dashboard): write our own code for kubernetes dashboard (#23797) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** ⚒️ Fixes # **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** **📃 Notes:** **✔️ Checklist:** - [ ] ⚖️ My code follows the style guidelines of this project - [ ] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [ ] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [ ] ⬆️ I increased versions for any altered app according to semantic versioning - [ ] I made sure the title starts with `feat(chart-name):`, `fix(chart-name):` or `chore(chart-name):` **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._ --------- Signed-off-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Signed-off-by: Kjeld Schouten Co-authored-by: Stavros kois Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com> --- .github/scripts/install_dependencies.sh | 10 + .../premium/kubernetes-dashboard/Chart.yaml | 13 +- .../premium/kubernetes-dashboard/values.yaml | 379 +++++++++++++++++- 3 files changed, 385 insertions(+), 17 deletions(-) diff --git a/.github/scripts/install_dependencies.sh b/.github/scripts/install_dependencies.sh index c094993f219..fa597090a4d 100755 --- a/.github/scripts/install_dependencies.sh +++ b/.github/scripts/install_dependencies.sh @@ -83,3 +83,13 @@ if [[ "$curr_chart" == "charts/system/intel-device-plugins-operator" ]]; then fi echo "Done installing cert-manager chart" fi + +if [[ "$curr_chart" == "charts/premium/kubernetes-dashboard" ]]; then + echo "Installing metrics-server chart" + helm install traefik oci://tccr.io/truecharts/metrics-server --namespace cert-manager --create-namespace --wait + if [[ "$?" != "0" ]]; then + echo "Failed to install metrics-server chart" + exit 1 + fi + echo "Done installing metrics-server chart" +fi diff --git a/charts/premium/kubernetes-dashboard/Chart.yaml b/charts/premium/kubernetes-dashboard/Chart.yaml index 6094d80478c..3376bac4d38 100644 --- a/charts/premium/kubernetes-dashboard/Chart.yaml +++ b/charts/premium/kubernetes-dashboard/Chart.yaml @@ -15,13 +15,10 @@ dependencies: alias: "" tags: [] import-values: [] - - name: kubernetes-dashboard - version: 5.10.0 - repository: oci://ghcr.io/elfhosted/charts - condition: "" - alias: kubernetes-dashboard - tags: [] - import-values: [] + - name: kong + version: 2.38.0 + repository: https://charts.konghq.com + condition: kong.enabled deprecated: false description: The default Kubernetes Dashboard home: https://truecharts.org/charts/system/kubernetes-dashboard @@ -41,4 +38,4 @@ sources: - https://github.com/truecharts/containers/tree/master/apps/alpine - https://kubernetes-dashboard.universe.tf type: application -version: 0.0.3 +version: 1.0.0 diff --git a/charts/premium/kubernetes-dashboard/values.yaml b/charts/premium/kubernetes-dashboard/values.yaml index ac94d326584..e319857d93b 100644 --- a/charts/premium/kubernetes-dashboard/values.yaml +++ b/charts/premium/kubernetes-dashboard/values.yaml @@ -1,25 +1,386 @@ image: - repository: tccr.io/tccr/alpine + repository: kubernetesui/dashboard-web pullPolicy: IfNotPresent - tag: latest@sha256:783d7b4da265da6ee627fe54ee895a2cfe2a2ecd7bb7b53a0c7a703a924a8e82 + tag: 1.4.0 + +authImage: + repository: docker.io/kubernetesui/dashboard-auth + pullPolicy: IfNotPresent + tag: 1.1.3 + +apiImage: + repository: kubernetesui/dashboard-api + pullPolicy: IfNotPresent + tag: 1.7.0 + +scraperImage: + repository: kubernetesui/dashboard-metrics-scraper + pullPolicy: IfNotPresent + tag: 1.1.1 service: + # TODO: Point main to kong! main: - enabled: false + enabled: true ports: main: - enabled: false + enabled: true + primary: true + port: 443 + targetPort: 8443 + protocol: https + selectorLabels: + app.kubernetes.io/name: kong + app.kubernetes.io/component: app + kubernetes-dashboard-web: + expandObjectName: false + enabled: true + targetSelector: main + ports: + web: + enabled: true + port: 8000 + targetPort: 8000 + protocol: http + kubernetes-dashboard-api: + expandObjectName: false + enabled: true + targetSelector: api + ports: + api: + enabled: true + port: 8000 + targetPort: 8000 + protocol: http + kubernetes-dashboard-auth: + expandObjectName: false + enabled: true + targetSelector: auth + ports: + auth: + enabled: true + port: 8000 + targetPort: 8000 + protocol: http + kubernetes-dashboard-scraper: + expandObjectName: false + enabled: true + targetSelector: scraper + ports: + scraper: + enabled: true + port: 8000 + targetPort: 8000 + protocol: http workload: main: - enabled: false + enabled: true + podSpec: + containers: + main: + enabled: true + args: + - --namespace={{ .Release.Namespace }} + - --settings-config-map-name=kubernetes-dashboard-settings + # GOMAXPROCS: + # resourceFieldRef: + # resource: limits.cpu + # GOMEMLIMIT: + # valueFrom: + # resourceFieldRef: + # resource: limits.memory + probes: + liveness: + enabled: true + type: http + port: 8000 + readiness: + enabled: true + type: http + port: 8000 + startup: + enabled: true + type: http + port: 8000 + api: + enabled: true + type: Deployment + podSpec: + containers: + api: + enabled: true + primary: true + imageSelector: apiImage + args: + - --namespace={{ .Release.Namespace }} + - --metrics-scraper-service-name=kubernetes-dashboard-scraper + env: + CSRF_KEY: + secretKeyRef: + name: csrf + key: private.key + + # GOMAXPROCS: + # resourceFieldRef: + # resource: limits.cpu + # GOMEMLIMIT: + # valueFrom: + # resourceFieldRef: + # resource: limits.memory + + probes: + liveness: + enabled: true + type: http + port: 8000 + path: /metrics + readiness: + enabled: true + type: http + port: 8000 + path: /metrics + startup: + enabled: true + type: http + port: 8000 + path: /metrics + + auth: + enabled: true + type: Deployment + podSpec: + containers: + auth: + enabled: true + primary: true + imageSelector: authImage + env: + CSRF_KEY: + secretKeyRef: + name: csrf + key: private.key + + # GOMAXPROCS: + # resourceFieldRef: + # resource: limits.cpu + # GOMEMLIMIT: + # valueFrom: + # resourceFieldRef: + # resource: limits.memory + + probes: + liveness: + enabled: true + type: tcp + port: 8000 + readiness: + enabled: true + type: tcp + port: 8000 + startup: + enabled: true + type: tcp + port: 8000 + + scraper: + enabled: true + type: Deployment + podSpec: + containers: + scraper: + enabled: true + primary: true + imageSelector: scraperImage + env: + CSRF_KEY: + secretKeyRef: + name: csrf + key: private.key + + # GOMAXPROCS: + # resourceFieldRef: + # resource: limits.cpu + # GOMEMLIMIT: + # valueFrom: + # resourceFieldRef: + # resource: limits.memory + probes: + liveness: + enabled: true + type: http + port: 8000 + readiness: + enabled: true + type: http + port: 8000 + startup: + enabled: true + type: http + port: 8000 + +podOptions: + automountServiceAccountToken: true + +configmap: + kubernetes-dashboard-settings: + expandObjectName: false + enabled: true + data: + settings: '{"itemsPerPage":100}' + kubedashboard-konggateway: + enabled: true + expandObjectName: false + data: + kong.yml: | + _format_version: "3.0" + services: + - name: auth + host: kubernetes-dashboard-auth + port: 8000 + protocol: http + routes: + - name: authLogin + paths: + - /api/v1/login + strip_path: false + - name: authCsrf + paths: + - /api/v1/csrftoken/login + strip_path: false + - name: authMe + paths: + - /api/v1/me + strip_path: false + - name: api + host: kubernetes-dashboard-api + port: 8000 + protocol: http + routes: + - name: api + paths: + - /api + strip_path: false + - name: metrics + paths: + - /metrics + strip_path: false + - name: web + host: kubernetes-dashboard-web + port: 8000 + protocol: http + routes: + - name: root + paths: + - / + strip_path: false + + +secret: + csrf: + enabled: true + data: + private.key: ZHdwY1JlYTlCWkVhWVEydmEvdXA2dUwzOUdERkFZN2JCcFU0a25UM3dnZVVOazlHUGFpWmptaXNhS3VMdUVvS2o1VENJUTdnKzlpZzA3S3BZYzM0MVpiVjNBSlBsMzZZSFN5eC9Rdi9uMnlaVDlYZ3BOb0IyRk02ZjBnczhEcXVxU0V1aWd4aC9rSEpSRVVpSFFtUUNrMDlTSG10ZFkzRnBpb1UzMGdlNjlNQ1JtdERmdmRoOVhteXRBYjR1M3VxeElmQWQ5QmRKcEdoZzZtMGVJQU15QnRNdHZaMnl6eVRhWjJPdXVLZnNwdVFaZThhYjJCcCtQSGxLOFNrcTY0RS9STzJVdzRjblFHTXFjQXhhdEszZEVPMmhtR1hOMm1uWVhxQXN3S0hIeWJBV2xCVW1UT3JDSFJuY1M3N3kyZjQwSk9PbWRoa0ZSREZJcWdOVC95aTd3PT0= portal: open: + enabled: true + +## TODO: Split into multiple rbacs +## TODO: Implement these: https://github.com/kubernetes/dashboard/tree/master/charts/kubernetes-dashboard/templates/rbac/api +rbac: + main: + enabled: true + primary: true + clusterWide: true + rules: + - apiGroups: [""] + resources: ["secrets"] + resourceNames: ["kubernetes-dashboard-key-holder", "kubernetes-dashboard-certs", "kubernetes-dashboard-csrf"] + verbs: ["get", "update", "delete"] + # Allow Dashboard to get and update 'kubernetes-dashboard-settings' config map. + - apiGroups: [""] + resources: ["configmaps"] + resourceNames: ["kubernetes-dashboard-settings"] + verbs: ["get", "update"] + # Allow Dashboard to get metrics. + - apiGroups: [""] + resources: ["services"] + resourceNames: ["heapster", "dashboard-metrics-scraper"] + verbs: ["proxy"] + - apiGroups: [""] + resources: ["services/proxy"] + resourceNames: ["heapster", "http:heapster:", "https:heapster:", "dashboard-metrics-scraper", "http:dashboard-metrics-scraper"] + verbs: ["get"] + - apiGroups: ["metrics.k8s.io"] + resources: ["pods", "nodes"] + verbs: ["get", "list", "watch"] + # Give all-access + - apiGroups: ["*"] + resources: ["*"] + verbs: ["*"] + +# -- The service account the pods will use to interact with the Kubernetes API +serviceAccount: + main: + enabled: true + primary: true + targetSelectAll: true + +## Required Kong sub-chart with DBless configuration to act as a gateway +## for our all containers. +kong: + enabled: true + ## Configuration reference: https://docs.konghq.com/gateway/3.6.x/reference/configuration + env: + dns_order: LAST,A,CNAME,AAAA,SRV + plugins: 'off' + nginx_worker_processes: 1 + ingressController: enabled: false + dblessConfig: + configMap: kubedashboard-konggateway + proxy: + type: ClusterIP + http: + enabled: false -operator: - register: true -manifestManager: - enabled: false +## TODO Pre-configure ingress if needed +## Ingress hint: +# apiVersion: traefik.io/v1alpha1 +# kind: IngressRoute +# metadata: +# name: kubdashboard-ingressroute +# namespace: kubernetes-dashboard +# spec: +# entryPoints: [websecure] +# routes: +# - kind: Rule +# match: PathPrefix(`/kubernetes-dashboard`) +# services: +# - kind: Service +# name: kubernetes-dashboard-kong-proxy +# namespace: kubernetes-dashboard +# port: kong-proxy +# middlewares: +# - name: stripkubdashboard +# namespace: kubernetes-dashboard +# +# --- +# +# apiVersion: traefik.io/v1alpha1 +# kind: Middleware +# metadata: +# name: stripkubdashboard +# namespace: kubernetes-dashboard +# spec: +# stripPrefix: +# prefixes: +# - "/kubernetes-dashboard" +# forceSlash: true + +# kong: +# proxy: +# http: +# enabled: true