Skip to content
This repository was archived by the owner on Oct 28, 2024. It is now read-only.

Commit c9b44e4

Browse files
Implement the NestedControllerManager controller
1 parent a2cecf1 commit c9b44e4

16 files changed

+614
-10
lines changed

PROJECT

+5
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,9 @@ resources:
1717
group: controlplane
1818
kind: NestedAPIServer
1919
version: v1alpha4
20+
- api:
21+
crdVersion: v1
22+
group: controlplane
23+
kind: NestedControllerManager
24+
version: v1alpha4
2025
version: 3-alpha
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
Copyright 2021 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha4
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
addonv1alpha1 "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/apis/v1alpha1"
22+
)
23+
24+
// NestedControllerManagerSpec defines the desired state of NestedControllerManager
25+
type NestedControllerManagerSpec struct {
26+
// NestedComponentSpec contains the common and user-specified information
27+
// that are required for creating the component
28+
// +optional
29+
NestedComponentSpec `json:",inline"`
30+
}
31+
32+
// NestedControllerManagerStatus defines the observed state of NestedControllerManager
33+
type NestedControllerManagerStatus struct {
34+
// CommonStatus allows addons status monitoring
35+
addonv1alpha1.CommonStatus `json:",inline"`
36+
}
37+
38+
//+kubebuilder:object:root=true
39+
//+kubebuilder:subresource:status
40+
41+
// NestedControllerManager is the Schema for the nestedcontrollermanagers API
42+
type NestedControllerManager struct {
43+
metav1.TypeMeta `json:",inline"`
44+
metav1.ObjectMeta `json:"metadata,omitempty"`
45+
46+
Spec NestedControllerManagerSpec `json:"spec,omitempty"`
47+
Status NestedControllerManagerStatus `json:"status,omitempty"`
48+
}
49+
50+
//+kubebuilder:object:root=true
51+
52+
// NestedControllerManagerList contains a list of NestedControllerManager
53+
type NestedControllerManagerList struct {
54+
metav1.TypeMeta `json:",inline"`
55+
metav1.ListMeta `json:"metadata,omitempty"`
56+
Items []NestedControllerManager `json:"items"`
57+
}
58+
59+
func init() {
60+
SchemeBuilder.Register(&NestedControllerManager{}, &NestedControllerManagerList{})
61+
}

apis/controlplane/v1alpha4/zz_generated.deepcopy.go

+91
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/component-templates/nested-apiserver/nested-apiserver-statefulset-template.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ spec:
88
serviceName: {{.nestedAPIServerName}}
99
selector:
1010
matchLabels:
11-
component-name: apiserver
11+
component-name: {{.nestedAPIServerName}}
1212
# apiserver will not be updated, unless it is deleted
1313
updateStrategy:
1414
type: OnDelete
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
apiVersion: apps/v1
2+
kind: StatefulSet
3+
metadata:
4+
name: {{.nestedControllerManagerName}}
5+
namespace: {{.nestedControllerManagerNamespace}}
6+
spec:
7+
selector:
8+
matchLabels:
9+
component-name: {{.nestedControllerManagerName}}
10+
updateStrategy:
11+
type: OnDelete
12+
template:
13+
metadata:
14+
labels:
15+
component-name: {{.nestedControllerManagerName}}
16+
spec:
17+
containers:
18+
- name: {{.nestedControllerManagerName}}
19+
image: virtualcluster/controller-manager-v1.16.2
20+
imagePullPolicy: Always
21+
command:
22+
- kube-controller-manager
23+
args:
24+
- --bind-address=0.0.0.0
25+
- --cluster-cidr=10.200.0.0/16
26+
- --cluster-signing-cert-file=/etc/kubernetes/pki/root/tls.crt
27+
- --cluster-signing-key-file=/etc/kubernetes/pki/root/tls.key
28+
- --kubeconfig=/etc/kubernetes/kubeconfig/controller-manager-kubeconfig
29+
- --authorization-kubeconfig=/etc/kubernetes/kubeconfig/controller-manager-kubeconfig
30+
- --authentication-kubeconfig=/etc/kubernetes/kubeconfig/controller-manager-kubeconfig
31+
# control plane contains only one instance for now
32+
- --leader-elect=false
33+
- --root-ca-file=/etc/kubernetes/pki/root/tls.crt
34+
- --service-account-private-key-file=/etc/kubernetes/pki/service-account/tls.key
35+
- --service-cluster-ip-range=10.32.0.0/24
36+
- --use-service-account-credentials=true
37+
- --experimental-cluster-signing-duration=87600h
38+
- --node-monitor-grace-period=200s
39+
- --v=2
40+
livenessProbe:
41+
httpGet:
42+
path: /healthz
43+
port: 10252
44+
scheme: HTTP
45+
failureThreshold: 8
46+
initialDelaySeconds: 15
47+
periodSeconds: 10
48+
timeoutSeconds: 15
49+
readinessProbe:
50+
httpGet:
51+
port: 10252
52+
path: /healthz
53+
scheme: HTTP
54+
failureThreshold: 8
55+
initialDelaySeconds: 15
56+
periodSeconds: 2
57+
timeoutSeconds: 15
58+
volumeMounts:
59+
- mountPath: /etc/kubernetes/pki/root
60+
name: {{.nestedControlPlaneName}}-apiserver
61+
readOnly: true
62+
- mountPath: /etc/kubernetes/pki/service-account
63+
name: {{.nestedControlPlaneName}}-sa
64+
readOnly: true
65+
- mountPath: /etc/kubernetes/kubeconfig
66+
name: {{.nestedControllerManagerName}}-kubeconfig
67+
readOnly: true
68+
volumes:
69+
- name: {{.nestedControlPlaneName}}-apiserver
70+
secret:
71+
defaultMode: 420
72+
secretName: {{.nestedControlPlaneName}}-apiserver
73+
- name: {{.nestedControlPlaneName}}-sa
74+
secret:
75+
defaultMode: 420
76+
secretName: {{.nestedControlPlaneName}}-sa
77+
- name: {{.nestedControllerManagerName}}-kubeconfig
78+
secret:
79+
defaultMode: 420
80+
secretName: {{.nestedControllerManagerName}}-kubeconfig
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
2+
---
3+
apiVersion: apiextensions.k8s.io/v1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
controller-gen.kubebuilder.io/version: v0.4.1-0.20201002000720-57250aac17f6
8+
creationTimestamp: null
9+
name: nestedcontrollermanagers.controlplane.cluster.x-k8s.io
10+
spec:
11+
group: controlplane.cluster.x-k8s.io
12+
names:
13+
kind: NestedControllerManager
14+
listKind: NestedControllerManagerList
15+
plural: nestedcontrollermanagers
16+
singular: nestedcontrollermanager
17+
scope: Namespaced
18+
versions:
19+
- name: v1alpha4
20+
schema:
21+
openAPIV3Schema:
22+
description: NestedControllerManager is the Schema for the nestedcontrollermanagers API
23+
properties:
24+
apiVersion:
25+
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
26+
type: string
27+
kind:
28+
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
29+
type: string
30+
metadata:
31+
type: object
32+
spec:
33+
description: NestedControllerManagerSpec defines the desired state of NestedControllerManager
34+
properties:
35+
channel:
36+
description: 'Channel specifies a channel that can be used to resolve a specific addon, eg: stable It will be ignored if Version is specified'
37+
type: string
38+
patches:
39+
items:
40+
type: object
41+
type: array
42+
replicas:
43+
description: Replicas defines the number of replicas in the component's workload
44+
format: int32
45+
type: integer
46+
resources:
47+
description: Resources defines the amount of computing resources that will be used by this component
48+
properties:
49+
limits:
50+
additionalProperties:
51+
anyOf:
52+
- type: integer
53+
- type: string
54+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
55+
x-kubernetes-int-or-string: true
56+
description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
57+
type: object
58+
requests:
59+
additionalProperties:
60+
anyOf:
61+
- type: integer
62+
- type: string
63+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
64+
x-kubernetes-int-or-string: true
65+
description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
66+
type: object
67+
type: object
68+
version:
69+
description: Version specifies the exact addon version to be deployed, eg 1.2.3 It should not be specified if Channel is specified
70+
type: string
71+
type: object
72+
status:
73+
description: NestedControllerManagerStatus defines the observed state of NestedControllerManager
74+
properties:
75+
errors:
76+
items:
77+
type: string
78+
type: array
79+
healthy:
80+
type: boolean
81+
phase:
82+
type: string
83+
required:
84+
- healthy
85+
type: object
86+
type: object
87+
served: true
88+
storage: true
89+
subresources:
90+
status: {}
91+
status:
92+
acceptedNames:
93+
kind: ""
94+
plural: ""
95+
conditions: []
96+
storedVersions: []

config/crd/kustomization.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ resources:
55
- bases/controlplane.cluster.x-k8s.io_nestedcontrolplanes.yaml
66
- bases/controlplane.cluster.x-k8s.io_nestedetcds.yaml
77
- bases/controlplane.cluster.x-k8s.io_nestedapiservers.yaml
8+
- bases/controlplane.cluster.x-k8s.io_nestedcontrollermanagers.yaml
89
# +kubebuilder:scaffold:crdkustomizeresource
910

1011
patchesStrategicMerge:
@@ -13,13 +14,15 @@ patchesStrategicMerge:
1314
#- patches/webhook_in_nestedcontrolplanes.yaml
1415
#- patches/webhook_in_nestedetcds.yaml
1516
#- patches/webhook_in_nestedapiservers.yaml
17+
#- patches/webhook_in_nestedcontrollermanagers.yaml
1618
# +kubebuilder:scaffold:crdkustomizewebhookpatch
1719

1820
# [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix.
1921
# patches here are for enabling the CA injection for each CRD
2022
#- patches/cainjection_in_nestedcontrolplanes.yaml
2123
#- patches/cainjection_in_nestedetcds.yaml
2224
#- patches/cainjection_in_nestedapiservers.yaml
25+
#- patches/cainjection_in_nestedcontrollermanagers.yaml
2326
# +kubebuilder:scaffold:crdkustomizecainjectionpatch
2427

2528
# the following config is for teaching kustomize how to do kustomization for CRDs.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# The following patch adds a directive for certmanager to inject CA into the CRD
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
7+
name: nestedcontrollermanagers.controlplane.cluster.x-k8s.io

0 commit comments

Comments
 (0)