Skip to content

Commit

Permalink
Add spoke-cluster-proxy chart (#11)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha authored Mar 12, 2024
1 parent 2d709d5 commit b7633cc
Show file tree
Hide file tree
Showing 12 changed files with 736 additions and 0 deletions.
12 changes: 12 additions & 0 deletions charts/spoke-cluster-proxy/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
description: Spoke Cluster Proxy
name: spoke-cluster-proxy
version: v2024.2.25
appVersion: v0.0.1
home: https://github.com/kluster-manager/cluster-proxy
icon: https://cdn.appscode.com/images/products/searchlight/icons/android-icon-192x192.png
sources:
- https://github.com/kluster-manager/cluster-proxy
maintainers:
- name: appscode
email: [email protected]
67 changes: 67 additions & 0 deletions charts/spoke-cluster-proxy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Spoke Cluster Proxy

[Spoke Cluster Proxy](https://github.com/kluster-manager/cluster-proxy) - Spoke Cluster Proxy

## TL;DR;

```bash
$ helm repo add appscode https://charts.appscode.com/stable
$ helm repo update
$ helm search repo appscode/spoke-cluster-proxy --version=v2024.2.25
$ helm upgrade -i spoke-cluster-proxy appscode/spoke-cluster-proxy -n c1 --create-namespace --version=v2024.2.25
```

## Introduction

This chart deploys a Spoke Cluster Proxy on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.

## Prerequisites

- Kubernetes 1.21+

## Installing the Chart

To install/upgrade the chart with the release name `spoke-cluster-proxy`:

```bash
$ helm upgrade -i spoke-cluster-proxy appscode/spoke-cluster-proxy -n c1 --create-namespace --version=v2024.2.25
```

The command deploys a Spoke Cluster Proxy on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.

> **Tip**: List all releases using `helm list`
## Uninstalling the Chart

To uninstall the `spoke-cluster-proxy`:

```bash
$ helm uninstall spoke-cluster-proxy -n c1
```

The command removes all the Kubernetes components associated with the chart and deletes the release.

## Configuration

The following table lists the configurable parameters of the `spoke-cluster-proxy` chart and their default values.

| Parameter | Description | Default |
|----------------------|-------------|----------------------------------------------------|
| nameOverride | | <code>""</code> |
| fullnameOverride | | <code>""</code> |
| kubeconfigSecretName | | <code>""</code> |
| kubectl.image | | <code>ghcr.io/appscode/kubectl-nonroot:1.25</code> |


Specify each parameter using the `--set key=value[,key=value]` argument to `helm upgrade -i`. For example:

```bash
$ helm upgrade -i spoke-cluster-proxy appscode/spoke-cluster-proxy -n c1 --create-namespace --version=v2024.2.25 --set kubectl.image=ghcr.io/appscode/kubectl-nonroot:1.25
```

Alternatively, a YAML file that specifies the values for the parameters can be provided while
installing the chart. For example:

```bash
$ helm upgrade -i spoke-cluster-proxy appscode/spoke-cluster-proxy -n c1 --create-namespace --version=v2024.2.25 --values values.yaml
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: addon.open-cluster-management.io/v1alpha1
kind: ManagedClusterAddOn
metadata:
name: cluster-proxy
namespace: {{ .Release.Namespace }}
spec:
installNamespace: open-cluster-management-cluster-proxy

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions charts/spoke-cluster-proxy/doc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
project:
name: Spoke Cluster Proxy
shortName: Spoke Cluster Proxy
url: https://github.com/kluster-manager/cluster-proxy
description: Spoke Cluster Proxy
app: a Spoke Cluster Proxy
repository:
url: https://charts.appscode.com/stable
name: appscode
chart:
name: spoke-cluster-proxy
values: -- generate from values file --
valuesExample: -- generate from values file --
prerequisites:
- Kubernetes 1.21+
release:
name: spoke-cluster-proxy
namespace: c1
69 changes: 69 additions & 0 deletions charts/spoke-cluster-proxy/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "spoke-cluster-proxy.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "spoke-cluster-proxy.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "spoke-cluster-proxy.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "spoke-cluster-proxy.labels" -}}
helm.sh/chart: {{ include "spoke-cluster-proxy.chart" . }}
{{ include "spoke-cluster-proxy.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "spoke-cluster-proxy.selectorLabels" -}}
app.kubernetes.io/name: {{ include "spoke-cluster-proxy.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "spoke-cluster-proxy.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "spoke-cluster-proxy.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Addon manager namespace
*/}}
{{- define "spoke-cluster-proxy.namespace" -}}
{{ ternary .Release.Namespace (required "A valid .Values.addonManagerNamespace is required!" .Values.addonManagerNamespace) (empty .Values.kubeconfigSecretName) }}
{{- end }}
6 changes: 6 additions & 0 deletions charts/spoke-cluster-proxy/templates/k8s/addon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{- if not .Values.kubeconfigSecretName }}

{{- $restpl := $.Files.Get "common/addon/managedclusteraddon.yaml" }}
{{ tpl $restpl $ }}

{{- end }}
43 changes: 43 additions & 0 deletions charts/spoke-cluster-proxy/templates/ocm-mc/addon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- if .Values.kubeconfigSecretName }}

apiVersion: batch/v1
kind: Job
metadata:
name: spoke-cluster-proxy-configure-addon
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/hook-weight": "2"
"helm.sh/hook": post-install,post-upgrade,post-rollback
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded,hook-failed
spec:
ttlSecondsAfterFinished: 0
backoffLimit: 3
template:
spec:
automountServiceAccountToken: false
containers:
- name: kubectl
image: {{ .Values.kubectl.image }}
workingDir: /var/run/secrets/ocm
command:
- sh
- -c
- |
sleep 2; \
kubectl --kubeconfig=auth/kubeconfig create ns {{ $.Release.Namespace }} || true; \
kubectl --kubeconfig=auth/kubeconfig apply -f - <<EOF
{{- $restpl := $.Files.Get "common/addon/managedclusteraddon.yaml" -}}
{{- tpl $restpl $ | nindent 14 }}
EOF
imagePullPolicy: {{ .Values.imagePullPolicy }}
volumeMounts:
- mountPath: /var/run/secrets/ocm/auth
name: ocm-auth
volumes:
- name: ocm-auth
secret:
defaultMode: 420
secretName: {{ .Values.kubeconfigSecretName }}
restartPolicy: Never

{{- end }}
62 changes: 62 additions & 0 deletions charts/spoke-cluster-proxy/templates/ocm-mc/crds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{- if .Values.kubeconfigSecretName }}
{{ range $path, $data := .Files.Glob "crds/**.yaml" }}

{{ $content := toString $data }}
{{ $crd := dig "spec" "names" "plural" "" ($content | fromYaml) }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: spoke-cluster-proxy-regcrd-{{ $crd }}
namespace: {{ $.Release.Namespace }}
annotations:
"helm.sh/hook-weight": "0"
"helm.sh/hook": post-install,post-upgrade,post-rollback
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded,hook-failed
data:
crd.yaml: |
{{- $content | nindent 4 }}
---
apiVersion: batch/v1
kind: Job
metadata:
name: spoke-cluster-proxy-regcrd-{{ $crd }}
namespace: {{ $.Release.Namespace }}
annotations:
"helm.sh/hook-weight": "1"
"helm.sh/hook": post-install,post-upgrade,post-rollback
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded,hook-failed
spec:
ttlSecondsAfterFinished: 0
backoffLimit: 3
template:
spec:
automountServiceAccountToken: false
containers:
- name: kubectl
image: {{ $.Values.kubectl.image }}
workingDir: /var/run/secrets/ocm
command:
- sh
- -c
- "sleep 2; \
kubectl --kubeconfig=auth/kubeconfig apply -f /etc/crds/crd.yaml; \
"
imagePullPolicy: {{ $.Values.imagePullPolicy }}
volumeMounts:
- mountPath: /var/run/secrets/ocm/auth
name: ocm-auth
- name: crd-volume
mountPath: /etc/crds
volumes:
- name: ocm-auth
secret:
defaultMode: 420
secretName: {{ $.Values.kubeconfigSecretName }}
- name: crd-volume
configMap:
name: spoke-cluster-proxy-regcrd-{{ $crd }}
restartPolicy: Never
{{- end }}
{{- end }}
41 changes: 41 additions & 0 deletions charts/spoke-cluster-proxy/values.openapiv3_schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
properties:
addonManagerNamespace:
type: string
fullnameOverride:
type: string
image:
type: string
imagePullPolicy:
type: string
kubeconfigSecretName:
type: string
kubectl:
properties:
image:
type: string
required:
- image
type: object
nameOverride:
type: string
placement:
properties:
create:
type: boolean
name:
type: string
required:
- create
- name
type: object
registryFQDN:
type: string
tag:
type: string
required:
- image
- imagePullPolicy
- kubectl
- placement
- registryFQDN
type: object
7 changes: 7 additions & 0 deletions charts/spoke-cluster-proxy/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
nameOverride: ""
fullnameOverride: ""

kubeconfigSecretName: ""

kubectl:
image: ghcr.io/appscode/kubectl-nonroot:1.25
4 changes: 4 additions & 0 deletions hack/scripts/import-crds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ crd-importer \
--input=https://github.com/open-cluster-management-io/api/raw/${OPEN_CLUSTER_MANAGEMENT_IO_API_TAG}/cluster/v1beta2/0000_01_clusters.open-cluster-management.io_managedclustersetbindings.crd.yaml \
--input=https://github.com/kluster-manager/managed-serviceaccount/raw/main/config/crd/bases/authentication.open-cluster-management.io_managedserviceaccounts.yaml \
--out=./charts/managed-serviceaccount-manager/crds

crd-importer \
--input=https://github.com/open-cluster-management-io/api/raw/${OPEN_CLUSTER_MANAGEMENT_IO_API_TAG}/addon/v1alpha1/0000_01_addon.open-cluster-management.io_managedclusteraddons.crd.yaml \
--out=./charts/spoke-cluster-proxy/crds

0 comments on commit b7633cc

Please sign in to comment.