Skip to content

Commit

Permalink
add kubeconfig to every tenant
Browse files Browse the repository at this point in the history
  • Loading branch information
klinch0 committed Dec 2, 2024
1 parent 59d4c5c commit 3900564
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/apps/tenant/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ description: Separated tenant namespace
icon: /logos/tenant.svg

type: application
version: 1.6.0
version: 1.6.1
59 changes: 59 additions & 0 deletions packages/apps/tenant/templates/kubeconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
{{- $host := index $cozyConfig.data "root-host" }}
{{- $apiServerAdress := index $cozyConfig.data "api-server-adress" }}
{{- $k8sClientSecret := lookup "v1" "Secret" "cozy-keycloak" "k8s-client" }}
{{- $k8sClient := index $k8sClientSecret.data "client-secret-key" | b64dec }}
{{- $rootSaConfigMap := lookup "v1" "ConfigMap" "kube-system" "kube-root-ca.crt" }}
{{- $k8sCa := index $rootSaConfigMap.data "ca.crt" | b64enc }}

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "tenant.name" . }}-dashboard-resources
namespace: {{ .Release.namespace }}
rules:
- apiGroups:
- ""
resources:
- secrets
resourceNames:
- kubeconfig-{{ include "tenant.name" . }}
verbs: ["get", "list", "watch"]


---

apiVersion: v1
kind: Secret
metadata:
name: kubeconfig-{{ include "tenant.name" . }}
namespace: tenant-root
stringData:
kubeconfig: |
apiVersion: v1
clusters:
- cluster:
server: https://{{ $apiServerAdress }}:6443
certificate-authority-data: {{ $k8sCa }}
name: cluster
contexts:
- context:
cluster: cluster
namespace: {{ include "tenant.name" . }}
user: keycloak
name: {{ include "tenant.name" . }}
current-context: default
users:
- name: keycloak
user:
exec:
apiVersion: client.authentication.k8s.io/v1beta1
args:
- oidc-login
- get-token
- --oidc-issuer-url=https://keycloak.{{ $host }}/realms/cozy
- --oidc-client-id=kubernetes
- --oidc-client-secret={{ $k8sClient }}
- --skip-open-browser
- --grant-type=password
command: kubectl
3 changes: 2 additions & 1 deletion packages/apps/versions_map
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ tenant 1.3.0 ceefae03
tenant 1.3.1 c56e5769
tenant 1.4.0 94c688f7
tenant 1.5.0 48128743
tenant 1.6.0 HEAD
tenant 1.6.0 df448b99
tenant 1.6.1 HEAD
virtual-machine 0.1.4 f2015d6
virtual-machine 0.1.5 7cd7de7
virtual-machine 0.2.0 5ca8823
Expand Down

0 comments on commit 3900564

Please sign in to comment.