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

Commit 6698808

Browse files
authored
Merge pull request #24 from charleszheng44/scaffolding
Add scaffolding
2 parents 00ca26f + 6b12e37 commit 6698808

38 files changed

+947
-4
lines changed

PROJECT

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
version: "2"
2-
domain: x-k8s.io
1+
domain: cluster.x.k8s.io
2+
layout: go.kubebuilder.io/v2
3+
projectName: capn
34
repo: sigs.k8s.io/cluster-api-provider-nested
5+
resources:
6+
- group: controlplane
7+
kind: NestedControlPlane
8+
version: v1alpha4
9+
version: 3-alpha

api/v1alpha4/groupversion_info.go

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright 2020 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 contains API Schema definitions for the controlplane v1alpha4 API group
18+
// +kubebuilder:object:generate=true
19+
// +groupName=controlplane.cluster.x.k8s.io
20+
package v1alpha4
21+
22+
import (
23+
"k8s.io/apimachinery/pkg/runtime/schema"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
25+
)
26+
27+
var (
28+
// GroupVersion is group version used to register these objects
29+
GroupVersion = schema.GroupVersion{Group: "controlplane.cluster.x.k8s.io", Version: "v1alpha4"}
30+
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
32+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
33+
34+
// AddToScheme adds the types in this group-version to the given scheme.
35+
AddToScheme = SchemeBuilder.AddToScheme
36+
)
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
Copyright 2020 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+
)
22+
23+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25+
26+
// NestedControlPlaneSpec defines the desired state of NestedControlPlane
27+
type NestedControlPlaneSpec struct {
28+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
29+
// Important: Run "make" to regenerate code after modifying this file
30+
31+
// Foo is an example field of NestedControlPlane. Edit NestedControlPlane_types.go to remove/update
32+
Foo string `json:"foo,omitempty"`
33+
}
34+
35+
// NestedControlPlaneStatus defines the observed state of NestedControlPlane
36+
type NestedControlPlaneStatus struct {
37+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
38+
// Important: Run "make" to regenerate code after modifying this file
39+
}
40+
41+
// +kubebuilder:object:root=true
42+
// +kubebuilder:subresource:status
43+
44+
// NestedControlPlane is the Schema for the nestedcontrolplanes API
45+
type NestedControlPlane struct {
46+
metav1.TypeMeta `json:",inline"`
47+
metav1.ObjectMeta `json:"metadata,omitempty"`
48+
49+
Spec NestedControlPlaneSpec `json:"spec,omitempty"`
50+
Status NestedControlPlaneStatus `json:"status,omitempty"`
51+
}
52+
53+
// +kubebuilder:object:root=true
54+
55+
// NestedControlPlaneList contains a list of NestedControlPlane
56+
type NestedControlPlaneList struct {
57+
metav1.TypeMeta `json:",inline"`
58+
metav1.ListMeta `json:"metadata,omitempty"`
59+
Items []NestedControlPlane `json:"items"`
60+
}
61+
62+
func init() {
63+
SchemeBuilder.Register(&NestedControlPlane{}, &NestedControlPlaneList{})
64+
}

api/v1alpha4/zz_generated.deepcopy.go

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

config/certmanager/certificate.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# The following manifests contain a self-signed issuer CR and a certificate CR.
2+
# More document can be found at https://docs.cert-manager.io
3+
# WARNING: Targets CertManager 0.11 check https://docs.cert-manager.io/en/latest/tasks/upgrading/index.html for
4+
# breaking changes
5+
apiVersion: cert-manager.io/v1alpha2
6+
kind: Issuer
7+
metadata:
8+
name: selfsigned-issuer
9+
namespace: system
10+
spec:
11+
selfSigned: {}
12+
---
13+
apiVersion: cert-manager.io/v1alpha2
14+
kind: Certificate
15+
metadata:
16+
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml
17+
namespace: system
18+
spec:
19+
# $(SERVICE_NAME) and $(SERVICE_NAMESPACE) will be substituted by kustomize
20+
dnsNames:
21+
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc
22+
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc.cluster.local
23+
issuerRef:
24+
kind: Issuer
25+
name: selfsigned-issuer
26+
secretName: webhook-server-cert # this secret will not be prefixed, since it's not managed by kustomize

config/certmanager/kustomization.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
resources:
2+
- certificate.yaml
3+
4+
configurations:
5+
- kustomizeconfig.yaml
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This configuration is for teaching kustomize how to update name ref and var substitution
2+
nameReference:
3+
- kind: Issuer
4+
group: cert-manager.io
5+
fieldSpecs:
6+
- kind: Certificate
7+
group: cert-manager.io
8+
path: spec/issuerRef/name
9+
10+
varReference:
11+
- kind: Certificate
12+
group: cert-manager.io
13+
path: spec/commonName
14+
- kind: Certificate
15+
group: cert-manager.io
16+
path: spec/dnsNames
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
---
3+
apiVersion: apiextensions.k8s.io/v1beta1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
controller-gen.kubebuilder.io/version: v0.3.0
8+
creationTimestamp: null
9+
name: nestedcontrolplanes.controlplane.cluster.x.k8s.io
10+
spec:
11+
group: controlplane.cluster.x.k8s.io
12+
names:
13+
kind: NestedControlPlane
14+
listKind: NestedControlPlaneList
15+
plural: nestedcontrolplanes
16+
singular: nestedcontrolplane
17+
scope: Namespaced
18+
subresources:
19+
status: {}
20+
validation:
21+
openAPIV3Schema:
22+
description: NestedControlPlane is the Schema for the nestedcontrolplanes API
23+
properties:
24+
apiVersion:
25+
description: 'APIVersion defines the versioned schema of this representation
26+
of an object. Servers should convert recognized schemas to the latest
27+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
28+
type: string
29+
kind:
30+
description: 'Kind is a string value representing the REST resource this
31+
object represents. Servers may infer this from the endpoint the client
32+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
33+
type: string
34+
metadata:
35+
type: object
36+
spec:
37+
description: NestedControlPlaneSpec defines the desired state of NestedControlPlane
38+
properties:
39+
foo:
40+
description: Foo is an example field of NestedControlPlane. Edit NestedControlPlane_types.go
41+
to remove/update
42+
type: string
43+
type: object
44+
status:
45+
description: NestedControlPlaneStatus defines the observed state of NestedControlPlane
46+
type: object
47+
type: object
48+
version: v1alpha4
49+
versions:
50+
- name: v1alpha4
51+
served: true
52+
storage: true
53+
status:
54+
acceptedNames:
55+
kind: ""
56+
plural: ""
57+
conditions: []
58+
storedVersions: []

config/crd/kustomization.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This kustomization.yaml is not intended to be run by itself,
2+
# since it depends on service name and namespace that are out of this kustomize package.
3+
# It should be run by config/default
4+
resources:
5+
- bases/controlplane.cluster.x.k8s.io_nestedcontrolplanes.yaml
6+
# +kubebuilder:scaffold:crdkustomizeresource
7+
8+
patchesStrategicMerge:
9+
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
10+
# patches here are for enabling the conversion webhook for each CRD
11+
#- patches/webhook_in_nestedcontrolplanes.yaml
12+
# +kubebuilder:scaffold:crdkustomizewebhookpatch
13+
14+
# [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix.
15+
# patches here are for enabling the CA injection for each CRD
16+
#- patches/cainjection_in_nestedcontrolplanes.yaml
17+
# +kubebuilder:scaffold:crdkustomizecainjectionpatch
18+
19+
# the following config is for teaching kustomize how to do kustomization for CRDs.
20+
configurations:
21+
- kustomizeconfig.yaml

config/crd/kustomizeconfig.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This file is for teaching kustomize how to substitute name and namespace reference in CRD
2+
nameReference:
3+
- kind: Service
4+
version: v1
5+
fieldSpecs:
6+
- kind: CustomResourceDefinition
7+
group: apiextensions.k8s.io
8+
path: spec/conversion/webhookClientConfig/service/name
9+
10+
namespace:
11+
- kind: CustomResourceDefinition
12+
group: apiextensions.k8s.io
13+
path: spec/conversion/webhookClientConfig/service/namespace
14+
create: false
15+
16+
varReference:
17+
- path: metadata/annotations
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# The following patch adds a directive for certmanager to inject CA into the CRD
2+
# CRD conversion requires k8s 1.13 or later.
3+
apiVersion: apiextensions.k8s.io/v1beta1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
8+
name: nestedcontrolplanes.controlplane.cluster.x.k8s.io

0 commit comments

Comments
 (0)