Skip to content

Commit a9eca86

Browse files
committed
feat: enable HCP deployment on external clusters
Signed-off-by: apedriza <adripedriza@gmail.com>
1 parent d5dcb3d commit a9eca86

File tree

44 files changed

+1609
-364
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1609
-364
lines changed

.github/workflows/go.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ jobs:
188188
- admission-webhook-k0s-not-compatible
189189
- k0smotron-upgrade
190190
- machinedeployment
191+
- remote-hosted-control-planes
191192

192193
steps:
193194
- name: Check out code into the Go module directory

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ run:
88
linters:
99
default: none
1010
enable:
11-
- depguard
1211
- goheader
1312
- revive
1413
settings:

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ generate-e2e-templates-main: $(KUSTOMIZE)
120120
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-webhook-recreate-in-single-mode --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-webhook-recreate-in-single-mode.yaml
121121
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-webhook-k0s-not-compatible --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-webhook-k0s-not-compatible.yaml
122122
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-machinedeployment --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-machinedeployment.yaml
123+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-remote-hcp --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-remote-hcp.yaml
124+
123125

124126
e2e: k0smotron-image-bundle.tar install.yaml kustomize generate-e2e-templates-main
125127
set +x;

api/k0smotron.io/v1beta1/k0smotroncluster_types.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ import (
3232

3333
// ClusterSpec defines the desired state of K0smotronCluster
3434
type ClusterSpec struct {
35+
// KubeconfigRef is the reference to the kubeconfig of the hosting cluster.
36+
// This kubeconfig will be used to deploy the k0s control plane.
37+
//+kubebuilder:validation:Optional
38+
KubeconfigRef *KubeconfigRef `json:"kubeconfigRef,omitempty"`
3539
// Replicas is the desired number of replicas of the k0s control planes.
3640
// If unspecified, defaults to 1. If the value is above 1, k0smotron requires kine datasource URL to be set.
3741
// Recommended value is 3.
@@ -324,6 +328,20 @@ type CertificateRef struct {
324328
Name string `json:"name,omitempty"`
325329
}
326330

331+
// KubeconfigRef defines the reference to the kubeconfig of the hosting cluster.
332+
type KubeconfigRef struct {
333+
// Name is the name of the secret containing the kubeconfig of the hosting cluster.
334+
//+kubebuilder:validation:Required
335+
Name string `json:"name"`
336+
// Namespace is the namespace of the secret containing the kubeconfig of the hosting cluster.
337+
//+kubebuilder:validation:Optional
338+
Namespace string `json:"namespace,omitempty"`
339+
// Key is the key in the secret containing the kubeconfig of the hosting cluster.
340+
//+kubebuilder:validation:Optional
341+
//+kubebuilder:default="value"
342+
Key string `json:"key,omitempty"`
343+
}
344+
327345
func init() {
328346
SchemeBuilder.Register(&Cluster{}, &ClusterList{})
329347
}

api/k0smotron.io/v1beta1/zz_generated.deepcopy.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/clusterapi/controlplane/bases/controlplane.cluster.x-k8s.io_k0smotroncontrolplanes.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,27 @@ spec:
260260
kineDataSourceURL:
261261
description: KineDataSourceURL defines the kine datasource URL.
262262
type: string
263+
kubeconfigRef:
264+
description: |-
265+
KubeconfigRef is the reference to the kubeconfig of the hosting cluster.
266+
This kubeconfig will be used to deploy the k0s control plane.
267+
properties:
268+
key:
269+
default: value
270+
description: Key is the key in the secret containing the kubeconfig
271+
of the hosting cluster.
272+
type: string
273+
name:
274+
description: Name is the name of the secret containing the kubeconfig
275+
of the hosting cluster.
276+
type: string
277+
namespace:
278+
description: Namespace is the namespace of the secret containing
279+
the kubeconfig of the hosting cluster.
280+
type: string
281+
required:
282+
- name
283+
type: object
263284
manifests:
264285
description: |-
265286
Manifests allows to specify list of volumes with manifests to be

config/clusterapi/controlplane/bases/controlplane.cluster.x-k8s.io_k0smotroncontrolplanetemplates.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,27 @@ spec:
247247
description: KineDataSourceURL defines the kine datasource
248248
URL.
249249
type: string
250+
kubeconfigRef:
251+
description: |-
252+
KubeconfigRef is the reference to the kubeconfig of the hosting cluster.
253+
This kubeconfig will be used to deploy the k0s control plane.
254+
properties:
255+
key:
256+
default: value
257+
description: Key is the key in the secret containing the
258+
kubeconfig of the hosting cluster.
259+
type: string
260+
name:
261+
description: Name is the name of the secret containing
262+
the kubeconfig of the hosting cluster.
263+
type: string
264+
namespace:
265+
description: Namespace is the namespace of the secret
266+
containing the kubeconfig of the hosting cluster.
267+
type: string
268+
required:
269+
- name
270+
type: object
250271
manifests:
251272
description: |-
252273
Manifests allows to specify list of volumes with manifests to be

config/clusterapi/k0smotron.io/bases/k0smotron.io_clusters.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,27 @@ spec:
222222
kineDataSourceURL:
223223
description: KineDataSourceURL defines the kine datasource URL.
224224
type: string
225+
kubeconfigRef:
226+
description: |-
227+
KubeconfigRef is the reference to the kubeconfig of the hosting cluster.
228+
This kubeconfig will be used to deploy the k0s control plane.
229+
properties:
230+
key:
231+
default: value
232+
description: Key is the key in the secret containing the kubeconfig
233+
of the hosting cluster.
234+
type: string
235+
name:
236+
description: Name is the name of the secret containing the kubeconfig
237+
of the hosting cluster.
238+
type: string
239+
namespace:
240+
description: Namespace is the namespace of the secret containing
241+
the kubeconfig of the hosting cluster.
242+
type: string
243+
required:
244+
- name
245+
type: object
225246
manifests:
226247
description: |-
227248
Manifests allows to specify list of volumes with manifests to be

config/crd/bases/controlplane/controlplane.cluster.x-k8s.io_k0smotroncontrolplanes.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,27 @@ spec:
260260
kineDataSourceURL:
261261
description: KineDataSourceURL defines the kine datasource URL.
262262
type: string
263+
kubeconfigRef:
264+
description: |-
265+
KubeconfigRef is the reference to the kubeconfig of the hosting cluster.
266+
This kubeconfig will be used to deploy the k0s control plane.
267+
properties:
268+
key:
269+
default: value
270+
description: Key is the key in the secret containing the kubeconfig
271+
of the hosting cluster.
272+
type: string
273+
name:
274+
description: Name is the name of the secret containing the kubeconfig
275+
of the hosting cluster.
276+
type: string
277+
namespace:
278+
description: Namespace is the namespace of the secret containing
279+
the kubeconfig of the hosting cluster.
280+
type: string
281+
required:
282+
- name
283+
type: object
263284
manifests:
264285
description: |-
265286
Manifests allows to specify list of volumes with manifests to be

config/crd/bases/controlplane/controlplane.cluster.x-k8s.io_k0smotroncontrolplanetemplates.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,27 @@ spec:
247247
description: KineDataSourceURL defines the kine datasource
248248
URL.
249249
type: string
250+
kubeconfigRef:
251+
description: |-
252+
KubeconfigRef is the reference to the kubeconfig of the hosting cluster.
253+
This kubeconfig will be used to deploy the k0s control plane.
254+
properties:
255+
key:
256+
default: value
257+
description: Key is the key in the secret containing the
258+
kubeconfig of the hosting cluster.
259+
type: string
260+
name:
261+
description: Name is the name of the secret containing
262+
the kubeconfig of the hosting cluster.
263+
type: string
264+
namespace:
265+
description: Namespace is the namespace of the secret
266+
containing the kubeconfig of the hosting cluster.
267+
type: string
268+
required:
269+
- name
270+
type: object
250271
manifests:
251272
description: |-
252273
Manifests allows to specify list of volumes with manifests to be

0 commit comments

Comments
 (0)