Skip to content

Commit

Permalink
Generate ace-cluster-info confgimap in spoke chart
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Sep 19, 2024
1 parent 5fbf090 commit 7826391
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 862 deletions.
36 changes: 3 additions & 33 deletions apis/installer/v1alpha1/cluster_manager_spoke_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,8 @@ type ClusterManagerSpokeSpec struct {

// Features is the slice of feature for work
// +optional
WorkFeatures []FeatureGate `json:"workFeatures"`
//+optional
ImagePullSecrets []string `json:"imagePullSecrets"`
ServiceAccount ServiceAccountSpec `json:"serviceAccount"`
PodSecurityContext core.PodSecurityContext `json:"podSecurityContext"`
SecurityContext core.SecurityContext `json:"securityContext"`
Resources core.ResourceRequirements `json:"resources"`
NodeSelector map[string]string `json:"nodeSelector"`
Tolerations []core.Toleration `json:"tolerations"`
Affinity core.Affinity `json:"affinity"`
Kubectl KubectlSpec `json:"kubectl"`
Secret core.ObjectReference `json:"secret"`
WorkFeatures []FeatureGate `json:"workFeatures"`
Secret core.ObjectReference `json:"secret"`
}

type KubectlSpec struct {
Expand All @@ -97,30 +87,10 @@ type ObjectReference struct {
}

type ClusterMetadata struct {
Uid string `json:"uid"`
// Name of the joined cluster on the hub
Name string `json:"name"`
ClusterManagers []string `json:"clusterManagers"`
// +optional
CAPI CapiMetadata `json:"capi"`
}

type CapiMetadata struct {
// +optional
Provider CAPIProvider `json:"provider"`
Namespace string `json:"namespace"`
Name string `json:"name"`
}

// +kubebuilder:validation:Enum=capa;capg;capz
type CAPIProvider string

const (
CAPIProviderDisabled CAPIProvider = ""
CAPIProviderCAPA CAPIProvider = "capa"
CAPIProviderCAPG CAPIProvider = "capg"
CAPIProviderCAPZ CAPIProvider = "capz"
)

// SpokeHub: The hub values for the template
type SpokeHub struct {
// APIServer: The API Server external URL
Expand Down
48 changes: 1 addition & 47 deletions apis/installer/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 19 additions & 35 deletions charts/cluster-manager-spoke/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,46 +45,30 @@ The command removes all the Kubernetes components associated with the chart and

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

| Parameter | Description | Default |
|----------------------------------------|------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------|
| clusterMetadata.uid | | <code>TBD</code> |
| clusterMetadata.name | | <code>TBD</code> |
| clusterMetadata.clusterManagers | | <code>[]</code> |
| clusterMetadata.capi.provider | | <code>""</code> |
| clusterMetadata.capi.namespace | | <code>""</code> |
| hub.apiServer | | <code>""</code> |
| hub.caData | | <code>""</code> |
| hub.token | | <code>""</code> |
| hub.kubeConfig | | <code>""</code> |
| registry | | <code>quay.io/open-cluster-management</code> |
| bundleVersion.registrationImageVersion | | <code>""</code> |
| bundleVersion.placementImageVersion | | <code>""</code> |
| bundleVersion.workImageVersion | | <code>""</code> |
| bundleVersion.operatorImageVersion | | <code>""</code> |
| bundleVersion.clusteradmImageVersion | | <code>latest</code> |
| managedKubeconfig | | <code>''</code> |
| registrationFeatures | | <code>[]</code> |
| workFeatures | | <code>[]</code> |
| imagePullSecrets | | <code>[]</code> |
| serviceAccount.create | Specifies whether a service account should be created | <code>true</code> |
| serviceAccount.annotations | Annotations to add to the service account | <code>{}</code> |
| serviceAccount.name | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | <code>""</code> |
| podSecurityContext | podAnnotations: {} podLabels: {} | <code>{}</code> |
| securityContext | | <code>{}</code> |
| resources | | <code>{}</code> |
| nodeSelector | | <code>{}</code> |
| tolerations | | <code>[]</code> |
| affinity | | <code>{}</code> |
| kubectl.image | | <code>ghcr.io/appscode/kubectl-nonroot:1.25</code> |
| kubectl.pullPolicy | | <code>IfNotPresent</code> |
| secret.name | | <code>opscenter-features-values</code> |
| secret.namespace | | <code>kubeops</code> |
| Parameter | Description | Default |
|----------------------------------------|-------------|----------------------------------------------|
| clusterMetadata.name | | <code>TBD</code> |
| hub.apiServer | | <code>""</code> |
| hub.caData | | <code>""</code> |
| hub.token | | <code>""</code> |
| hub.kubeConfig | | <code>""</code> |
| registry | | <code>quay.io/open-cluster-management</code> |
| bundleVersion.registrationImageVersion | | <code>""</code> |
| bundleVersion.placementImageVersion | | <code>""</code> |
| bundleVersion.workImageVersion | | <code>""</code> |
| bundleVersion.operatorImageVersion | | <code>""</code> |
| bundleVersion.clusteradmImageVersion | | <code>latest</code> |
| managedKubeconfig | | <code>''</code> |
| registrationFeatures | | <code>[]</code> |
| workFeatures | | <code>[]</code> |
| secret.name | | <code>ace-cluster-info</code> |
| secret.namespace | | <code>kubeops</code> |


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

```bash
$ helm upgrade -i cluster-manager-spoke appscode/cluster-manager-spoke -n open-cluster-management --create-namespace --version=v2024.7.10 --set clusterMetadata.uid=TBD
$ helm upgrade -i cluster-manager-spoke appscode/cluster-manager-spoke -n open-cluster-management --create-namespace --version=v2024.7.10 --set clusterMetadata.name=TBD
```

Alternatively, a YAML file that specifies the values for the parameters can be provided while
Expand Down
11 changes: 4 additions & 7 deletions charts/cluster-manager-spoke/templates/cluster_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ rules:
- apiGroups: ["work.open-cluster-management.io"]
resources: ["appliedmanifestworks"]
verbs: ["list", "update", "patch"]
# opscenter-feature-values
- apiGroups: [""]
resources: ["namespaces"]
verbs: ["get", "create"]
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "create", "update", "patch"]
# ace-cluster-info
- apiGroups: ["cluster.x-k8s.io"]
resources: ["clusters"]
verbs: ["get", "list", "watch"]
65 changes: 15 additions & 50 deletions charts/cluster-manager-spoke/templates/job.yaml
Original file line number Diff line number Diff line change
@@ -1,60 +1,25 @@
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "cluster-manager-spoke.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "cluster-manager-spoke.labels" . | nindent 4 }}
name: cluster-info-generator
namespace: open-cluster-management
annotations:
"helm.sh/hook": post-install,post-upgrade,post-rollback
spec:
ttlSecondsAfterFinished: 0
backoffLimit: 3
template:
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "cluster-manager-spoke.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
serviceAccountName: klusterlet
automountServiceAccountToken: true
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: {{ .Values.kubectl.image }}
imagePullPolicy: {{ .Values.kubectl.pullPolicy }}
command:
- sh
- -c
- |
set -x; \
sleep 2; \
ns={{ default .Release.Namespace $.Values.secret.namespace }}; \
kubectl get ns $ns|| kubectl create ns $ns; \
kubectl apply -f - <<EOF
apiVersion: v1
kind: Secret
metadata:
name: {{ $.Values.secret.name }}
namespace: {{ default .Release.Namespace $.Values.secret.namespace }}
labels:
{{- include "cluster-manager-spoke.labels" $ | nindent 20 }}
stringData:
values.yaml: |
clusterMetadata: {{ $.Values.clusterMetadata | toJson }}
EOF
resources:
{{- toYaml .Values.resources | nindent 12 }}
- name: clusteradm
image: ghcr.io/kluster-manager/clusteradm:{{ default .Chart.AppVersion .Values.bundleVersion.clusteradmImageVersion }}
imagePullPolicy: Always
args:
- /clusteradm
- get
- cluster-info
- --cluster-name={{ .Values.clusterMetadata.name }}
- --store-to-configmap={{ default .Release.Namespace .Values.secret.namespace }}/{{ .Values.secret.name }}
restartPolicy: Never
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
Loading

0 comments on commit 7826391

Please sign in to comment.