Skip to content

Commit 8f61cc0

Browse files
authored
Merge pull request #17636 from justinsb/clusterapi_controllers
More support for cluster-api
2 parents 4bfc346 + 7868e58 commit 8f61cc0

Some content is hidden

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

48 files changed

+1536
-378
lines changed

.ko.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
defaultLdflags:
2+
- -s -w
3+
- -X k8s.io/kops.Version={{.Env.VERSION}}
4+
- -X k8s.io/kops.GitVersion={{.Env.GITSHA}}

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ unexport AZURE_CLIENT_ID AZURE_CLIENT_SECRET AZURE_STORAGE_ACCOUNT AZURE_SUBSCRI
5454

5555

5656
VERSION=$(shell tools/get_version.sh | grep VERSION | awk '{print $$2}')
57+
export VERSION
58+
5759
IMAGE_TAG=$(shell tools/get_version.sh | grep IMAGE_TAG | awk '{print $$2}')
5860

5961
KOPS_CI_VERSION:=$(shell grep 'KOPS_CI_VERSION\s*=' kops-version.go | awk '{print $$3}' | sed -e 's_"__g')
@@ -62,6 +64,7 @@ KOPS_CI_VERSION:=$(shell grep 'KOPS_CI_VERSION\s*=' kops-version.go | awk '{prin
6264
KOPS=${DIST}/$(shell go env GOOS)/$(shell go env GOARCH)/kops
6365

6466
GITSHA := $(shell cd ${KOPS_ROOT}; git describe --always)
67+
export GITSHA
6568

6669
# We lock the versions of our controllers also
6770
# We need to keep in sync with:

clusterapi/README.md

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@ We plug in our own bootstrap provider with the goal of enabling cluster-api node
77
*Note*: the name & zone matter, we need to match the values we'll create later in the CAPI resources.
88

99
```
10-
kops create cluster clusterapi.k8s.local --zones us-east4-a
11-
kops update cluster clusterapi.k8s.local --yes --admin
12-
kops validate cluster --wait=10m
10+
go run ./cmd/kops create cluster clusterapi.k8s.local --zones us-east4-a
11+
go run ./cmd/kops update cluster clusterapi.k8s.local --yes --admin
12+
go run ./cmd/kops validate cluster --wait=10m
1313
```
1414

15-
#cd cluster-api-provider-gcp
16-
#REGISTRY=${USER} make docker-build docker-push
17-
#REGISTRY=${USER} make install-management-cluster # Doesn't yet exist in capg
18-
15+
# Install cert-manager
1916

17+
```
18+
kubectl apply --server-side -f https://github.com/cert-manager/cert-manager/releases/download/v1.18.2/cert-manager.yaml
2019
21-
# TODO: Install cert-manager
20+
kubectl wait --for=condition=Available --timeout=5m -n cert-manager deployment/cert-manager
21+
kubectl wait --for=condition=Available --timeout=5m -n cert-manager deployment/cert-manager-cainjector
22+
kubectl wait --for=condition=Available --timeout=5m -n cert-manager deployment/cert-manager-webhook
23+
```
2224

2325
# Install CAPI and CAPG
2426
```
@@ -29,7 +31,19 @@ kustomize build ${REPO_ROOT}/clusterapi/manifests/cluster-api-provider-gcp | kub
2931

3032
# Install our CRDs
3133
```
32-
kustomize build config | kubectl apply --server-side -f -
34+
kustomize build ${REPO_ROOT}/k8s | kubectl apply --server-side -f -
35+
kustomize build ${REPO_ROOT}/clusterapi/config | kubectl apply --server-side -f -
36+
```
37+
38+
## Create our Cluster object
39+
```
40+
go run ./cmd/kops get cluster clusterapi.k8s.local -oyaml | kubectl apply --server-side -n kube-system -f -
41+
```
42+
43+
## Create our instancegroup object
44+
45+
```
46+
go run ./cmd/kops get ig nodes-us-east4-a --name clusterapi.k8s.local -oyaml | kubectl apply --server-side -n kube-system -f -
3347
```
3448

3549
# Remove any stuff left over from previous runs
@@ -39,8 +53,11 @@ kubectl delete gcpmachinetemplate --all
3953
```
4054

4155
```
42-
# Very carefully create a MachineDeployment matching our configuration
43-
cat examples/manifest.yaml | IMAGE_ID=projects/ubuntu-os-cloud/global/images/family/ubuntu-2204-lts GCP_NODE_MACHINE_TYPE=e2-medium KUBERNETES_VERSION=v1.28.6 WORKER_MACHINE_COUNT=1 GCP_ZONE=us-east4-a GCP_REGION=us-east4 GCP_NETWORK_NAME=clusterapi-k8s-local GCP_SUBNET=us-east4-clusterapi-k8s-local GCP_PROJECT=$(gcloud config get project) CLUSTER_NAME=clusterapi-k8s-local envsubst | kubectl apply --server-side -n kube-system -f -
56+
# Create a MachineDeployment matching our configuration
57+
go run ./cmd/kops toolbox clusterapi generate machinedeployment \
58+
--cluster clusterapi.k8s.local \
59+
--name clusterapi-k8s-local-md-0 \
60+
--namespace kube-system | kubectl apply --server-side -n kube-system -f -
4461
```
4562

4663
# IMAGE_ID=projects/debian-cloud/global/images/family/debian-12 doesn't work with user-data (????)

clusterapi/config/crds/bootstrap.cluster.x-k8s.io_kopsconfigs.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clusterapi/config/crds/bootstrap.cluster.x-k8s.io_kopsconfigtemplates.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clusterapi/config/crds/controlplane.cluster.x-k8s.io_kopscontrolplanes.yaml

Lines changed: 41 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clusterapi/config/crds/controlplane.cluster.x-k8s.io_kopscontrolplanetemplates.yaml

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clusterapi/controlplane/kops/api/v1beta1/kopscontrolplane_types.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,64 @@ type KopsControlPlaneMachineTemplate struct {
4040

4141
// KopsControlPlaneStatus defines the observed state of KopsControlPlane.
4242
type KopsControlPlaneStatus struct {
43+
// initialization provides observations of the KopsControlPlane initialization process.
44+
// NOTE: Fields in this struct are part of the Cluster API contract and are used to orchestrate initial Machine provisioning.
45+
// +optional
46+
Initialization KopsControlPlaneInitializationStatus `json:"initialization,omitempty,omitzero"`
47+
48+
// KopsControllerEndpoint represents the endpoints used to communicate with the control plane.
49+
SystemEndpoints []SystemEndpoint `json:"systemEndpoints,omitempty"`
50+
}
51+
52+
// KopsControlPlaneInitializationStatus provides observations of the KopsControlPlane initialization process.
53+
// +kubebuilder:validation:MinProperties=1
54+
type KopsControlPlaneInitializationStatus struct {
55+
// controlPlaneInitialized is true when the KopsControlPlane provider reports that the Kubernetes control plane is initialized;
56+
// A control plane is considered initialized when it can accept requests, no matter if this happens before
57+
// the control plane is fully provisioned or not.
58+
// NOTE: this field is part of the Cluster API contract, and it is used to orchestrate initial Machine provisioning.
59+
// +optional
60+
ControlPlaneInitialized *bool `json:"controlPlaneInitialized,omitempty"`
61+
}
62+
63+
// SystemEndpointType identifies the service that the SystemEndpoint is describing.
64+
type SystemEndpointType string
65+
66+
const (
67+
// SystemEndpointTypeKubeAPIServer indicates that the endpoint is for the Kubernetes API server.
68+
SystemEndpointTypeKubeAPIServer SystemEndpointType = "kube-apiserver"
69+
// SystemEndpointTypeKopsController indicates that the endpoint is for the kops-controller.
70+
SystemEndpointTypeKopsController SystemEndpointType = "kops-controller"
71+
)
72+
73+
// SystemEndpointScope describes whether an endpoint is intended for internal or external use.
74+
type SystemEndpointScope string
75+
76+
const (
77+
// SystemEndpointScopeInternal indicates that the endpoint is intended for internal use.
78+
SystemEndpointScopeInternal SystemEndpointScope = "internal"
79+
// SystemEndpointScopeExternal indicates that the endpoint is intended for external use.
80+
SystemEndpointScopeExternal SystemEndpointScope = "external"
81+
)
82+
83+
// SystemEndpoint represents a reachable Kubernetes API endpoint.
84+
type SystemEndpoint struct {
85+
// The type of the endpoint
86+
Type SystemEndpointType `json:"type"`
87+
88+
// The hostname or IP on which the API server is serving.
89+
Endpoint string `json:"endpoint"`
90+
91+
// Whether the endpoint is intended for internal or external use.
92+
Scope SystemEndpointScope `json:"scope"`
4393
}
4494

4595
// +kubebuilder:object:root=true
4696
// +kubebuilder:resource:path=kopscontrolplanes,shortName=kcp,scope=Namespaced,categories=cluster-api
4797
// +kubebuilder:storageversion
4898
// +kubebuilder:subresource:status
4999
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.selector
100+
// +kubebuilder:metadata:labels=cluster.x-k8s.io/v1beta2=v1beta1
50101
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels['cluster\\.x-k8s\\.io/cluster-name']",description="Cluster"
51102
// +kubebuilder:printcolumn:name="Initialized",type=boolean,JSONPath=".status.initialized",description="This denotes whether or not the control plane has the uploaded kops-config configmap"
52103
// +kubebuilder:printcolumn:name="API Server Available",type=boolean,JSONPath=".status.ready",description="KopsControlPlane API Server is ready to receive requests"

clusterapi/controlplane/kops/api/v1beta1/kopscontrolplanetemplate_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type KopsControlPlaneTemplateSpec struct {
3131
// +kubebuilder:object:root=true
3232
// +kubebuilder:resource:path=kopscontrolplanetemplates,scope=Namespaced,categories=cluster-api
3333
// +kubebuilder:storageversion
34+
// +kubebuilder:metadata:labels=cluster.x-k8s.io/v1beta2=v1beta1
3435
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of KopsControlPlaneTemplate"
3536

3637
// KopsControlPlaneTemplate is the Schema for the kopscontrolplanetemplates API.

clusterapi/controlplane/kops/api/v1beta1/zz_generated.deepcopy.go

Lines changed: 42 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)