Skip to content

Commit

Permalink
Add adopted cluster template to adopt existing k8s clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
kylewuolle committed Dec 11, 2024
1 parent 673f0b4 commit 047904b
Show file tree
Hide file tree
Showing 10 changed files with 435 additions and 0 deletions.
16 changes: 16 additions & 0 deletions config/dev/adopted-clusterdeployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: hmc.mirantis.com/v1alpha1
kind: ClusterDeployment
metadata:
name: aws-dev
namespace: ${NAMESPACE}
spec:
template: adopted-cluster-0-0-4
credential: adopted-cluster-cred
config: {}
services:
- template: kyverno-3-2-6
name: kyverno
namespace: kyverno
- template: ingress-nginx-4-11-0
name: ingress-nginx
namespace: ingress-nginx
21 changes: 21 additions & 0 deletions config/dev/adopted-credentials.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v1
data:
value: ${KUBECONFIG_DATA}
kind: Secret
metadata:
name: adopted-cluster-kubeconf
namespace: ${NAMESPACE}
type: Opaque
---
apiVersion: hmc.mirantis.com/v1alpha1
kind: Credential
metadata:
name: adopted-cluster-cred
namespace: ${NAMESPACE}
spec:
description: Adopted Credentials
identityRef:
apiVersion: v1
kind: Secret
name: adopted-cluster-kubeconf
namespace: ${NAMESPACE}
23 changes: 23 additions & 0 deletions templates/cluster/adopted-cluster/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
11 changes: 11 additions & 0 deletions templates/cluster/adopted-cluster/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v2
name: adopted-cluster
description: |
An HMC template to adopt an already existing kubernetes cluster
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.4
annotations:
cluster.x-k8s.io/provider: infrastructure-internal
4 changes: 4 additions & 0 deletions templates/cluster/adopted-cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{- define "cluster.name" -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}

10 changes: 10 additions & 0 deletions templates/cluster/adopted-cluster/templates/sveltoscluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: lib.projectsveltos.io/v1beta1
kind: SveltosCluster
metadata:
labels:
projectsveltos.io/k8s-version: v1.31.1
name: {{ include "cluster.name" . }}
namespace: {{ .Release.Namespace }}
spec:
consecutiveFailureThreshold: {{ .Values.consecutiveFailureThreshold }}
kubeconfigName: {{ .Values.clusterIdentity.name }}
33 changes: 33 additions & 0 deletions templates/cluster/adopted-cluster/values.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"description": "An HMC template to adopt an existing k8s cluster.",
"type": "object",
"required": [
"clusterIdentity"
],
"properties": {
"consecutiveFailureThreshold": {
"description": "The number of the failures prior to setting the status condition",
"type": "integer",
"minimum": 1
},
"clusterIdentity": {
"type": "object",
"description": "Adopted Cluster Identity object reference",
"required": [
"name",
"kind"
],
"properties": {
"name": {
"description": "Adopted ClusterIdentity object name",
"type": "string"
},
"kind": {
"description": "Adopted ClusterIdentity object kind",
"type": "string"
}
}
}
}
}
7 changes: 7 additions & 0 deletions templates/cluster/adopted-cluster/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Cluster parameters

clusterIdentity:
name: "adopted-cluster-identity"
kind: "Secret"

consecutiveFailureThreshold: 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: hmc.mirantis.com/v1alpha1
kind: ClusterTemplate
metadata:
name: adopted-cluster-0-0-4
annotations:
helm.sh/resource-policy: keep
spec:
helm:
chartSpec:
chart: adopted-cluster
version: 0.0.4
interval: 10m0s
sourceRef:
kind: HelmRepository
name: hmc-templates
Loading

0 comments on commit 047904b

Please sign in to comment.