Skip to content

Commit b9eb318

Browse files
committed
Add initial APIs
On-behalf-of: @SAP [email protected] Signed-off-by: Marvin Beckers <[email protected]>
1 parent 7596b48 commit b9eb318

Some content is hidden

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

49 files changed

+3224
-8
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ go.work.sum
2323

2424
# env file
2525
.env
26+
27+
# Downloaded and built binaries
28+
bin/

PROJECT

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,45 @@ layout:
77
- go.kubebuilder.io/v4
88
projectName: kcp-operator
99
repo: github.com/kcp-dev/kcp-operator
10+
resources:
11+
- api:
12+
crdVersion: v1
13+
namespaced: true
14+
controller: true
15+
domain: operator.kcp.io
16+
kind: RootShard
17+
path: github.com/kcp-dev/kcp-operator/api/v1alpha1
18+
version: v1alpha1
19+
- api:
20+
crdVersion: v1
21+
namespaced: true
22+
controller: true
23+
domain: operator.kcp.io
24+
kind: FrontProxy
25+
path: github.com/kcp-dev/kcp-operator/api/v1alpha1
26+
version: v1alpha1
27+
- api:
28+
crdVersion: v1
29+
namespaced: true
30+
controller: true
31+
domain: operator.kcp.io
32+
kind: Shard
33+
path: github.com/kcp-dev/kcp-operator/api/v1alpha1
34+
version: v1alpha1
35+
- api:
36+
crdVersion: v1
37+
namespaced: true
38+
controller: true
39+
domain: operator.kcp.io
40+
kind: CacheServer
41+
path: github.com/kcp-dev/kcp-operator/api/v1alpha1
42+
version: v1alpha1
43+
- api:
44+
crdVersion: v1
45+
namespaced: true
46+
controller: true
47+
domain: operator.kcp.io
48+
kind: Kubeconfig
49+
path: github.com/kcp-dev/kcp-operator/api/v1alpha1
50+
version: v1alpha1
1051
version: "3"

api/v1alpha1/cacheserver_types.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
Copyright 2024 The KCP 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 v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// CacheServerSpec defines the desired state of CacheServer.
24+
type CacheServerSpec struct {
25+
// Etcd configures the etcd cluster that this cache server should be using.
26+
Etcd EtcdConfig `json:"etcd"`
27+
28+
// Optional: Image overwrites the container image used to deploy the cache server.
29+
Image *ImageSpec `json:"image,omitempty"`
30+
}
31+
32+
// CacheServerStatus defines the observed state of CacheServer
33+
type CacheServerStatus struct {
34+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
35+
// Important: Run "make" to regenerate code after modifying this file
36+
}
37+
38+
// +kubebuilder:object:root=true
39+
// +kubebuilder:subresource:status
40+
41+
// CacheServer is the Schema for the cacheservers API
42+
type CacheServer struct {
43+
metav1.TypeMeta `json:",inline"`
44+
metav1.ObjectMeta `json:"metadata,omitempty"`
45+
46+
Spec CacheServerSpec `json:"spec,omitempty"`
47+
Status CacheServerStatus `json:"status,omitempty"`
48+
}
49+
50+
// +kubebuilder:object:root=true
51+
52+
// CacheServerList contains a list of CacheServer
53+
type CacheServerList struct {
54+
metav1.TypeMeta `json:",inline"`
55+
metav1.ListMeta `json:"metadata,omitempty"`
56+
Items []CacheServer `json:"items"`
57+
}
58+
59+
func init() {
60+
SchemeBuilder.Register(&CacheServer{}, &CacheServerList{})
61+
}

api/v1alpha1/common.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
Copyright 2024 The KCP 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 v1alpha1
18+
19+
import (
20+
corev1 "k8s.io/api/core/v1"
21+
)
22+
23+
// ImageSpec defines settings for using a specific image and overwriting the default images used.
24+
type ImageSpec struct {
25+
// Repository is the container image repository to use for KCP containers. Defaults to `ghcr.io/kcp-dev/kcp`.
26+
Repository string `json:"repository,omitempty"`
27+
// Tag is the container image tag to use for KCP containers. Defaults to the latest kcp release that the operator supports.
28+
Tag string `json:"tag,omitempty"`
29+
// Optional: ImagePullSecrets is a list of secret references that should be used as image pull secrets (e.g. when a private registry is used).
30+
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
31+
}
32+
33+
type RootShardConfig struct {
34+
// Reference references a local RootShard object.
35+
Reference *corev1.ObjectReference `json:"ref,omitempty"`
36+
}
37+
38+
type EtcdConfig struct {
39+
// Endpoints is a list of http urls at which etcd nodes are available. The expected format is "https://etcd-hostname:2379".
40+
Endpoints []string `json:"endpoints"`
41+
// ClientCert configures the client certificate used to access etcd.
42+
ClientCert EtcdCertificate `json:"clientCert"`
43+
}
44+
45+
type EtcdCertificate struct {
46+
// SecretRef is the reference to a v1.Secret object that contains the TLS certificate.
47+
SecretRef corev1.LocalObjectReference `json:"secretRef"`
48+
}

api/v1alpha1/frontproxy_types.go

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
Copyright 2024 The KCP 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 v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// FrontProxySpec defines the desired state of FrontProxy.
24+
type FrontProxySpec struct {
25+
// RootShard configures the kcp root shard that this front-proxy instance should connect to.
26+
RootShard RootShardConfig `json:"rootShard"`
27+
// Optional: Replicas configures the replica count for the front-proxy Deployment.
28+
Replicas *int32 `json:"replicas,omitempty"`
29+
// Optional: Auth configures various aspects of Authentication and Authorization for this front-proxy instance.
30+
Auth *AuthSpec `json:"auth,omitempty"`
31+
}
32+
33+
type AuthSpec struct {
34+
// Optional: OIDC configures OpenID Connect Authentication
35+
OIDC *OIDCConfiguration `json:"oidc,omitempty"`
36+
}
37+
38+
// FrontProxyStatus defines the observed state of FrontProxy
39+
type FrontProxyStatus struct {
40+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
41+
// Important: Run "make" to regenerate code after modifying this file
42+
}
43+
44+
// +kubebuilder:object:root=true
45+
// +kubebuilder:subresource:status
46+
47+
// FrontProxy is the Schema for the frontproxies API
48+
type FrontProxy struct {
49+
metav1.TypeMeta `json:",inline"`
50+
metav1.ObjectMeta `json:"metadata,omitempty"`
51+
52+
Spec FrontProxySpec `json:"spec,omitempty"`
53+
Status FrontProxyStatus `json:"status,omitempty"`
54+
}
55+
56+
// +kubebuilder:object:root=true
57+
58+
// FrontProxyList contains a list of FrontProxy
59+
type FrontProxyList struct {
60+
metav1.TypeMeta `json:",inline"`
61+
metav1.ListMeta `json:"metadata,omitempty"`
62+
Items []FrontProxy `json:"items"`
63+
}
64+
65+
func init() {
66+
SchemeBuilder.Register(&FrontProxy{}, &FrontProxyList{})
67+
}

api/v1alpha1/groupversion_info.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright 2024 The KCP 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 v1alpha1 contains API Schema definitions for the v1alpha1 API group
18+
// +kubebuilder:object:generate=true
19+
// +groupName=operator.kcp.io
20+
package v1alpha1
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: "operator.kcp.io", Version: "v1alpha1"}
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+
)

api/v1alpha1/kubeconfig_types.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
Copyright 2024 The KCP 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 v1alpha1
18+
19+
import (
20+
corev1 "k8s.io/api/core/v1"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
)
23+
24+
// KubeconfigSpec defines the desired state of Kubeconfig.
25+
type KubeconfigSpec struct {
26+
// Target configures which kcp-operator object this kubeconfig should be generated for (shard or front-proxy).
27+
Target KubeconfigTarget `json:"target"`
28+
29+
// Username defines the username embedded in the TLS certificate generated for this kubeconfig.
30+
Username string `json:"username"`
31+
// Username defines the groups embedded in the TLS certificate generated for this kubeconfig.
32+
Groups []string `json:"groups,omitempty"`
33+
34+
// Validity configures the lifetime of the embedded TLS certificate. The kubeconfig secret will be automatically regenerated when the certificate expires.
35+
Validity metav1.Time `json:"validity"`
36+
37+
// SecretRef defines the v1.Secret object that the resulting kubeconfig should be written to.
38+
SecretRef corev1.LocalObjectReference `json:"secretRef"`
39+
}
40+
41+
type KubeconfigTarget struct {
42+
RootShardRef *corev1.LocalObjectReference `json:"rootShardRef,omitempty"`
43+
ShardRef *corev1.LocalObjectReference `json:"shardRef,omitempty"`
44+
FrontProxyRef *corev1.LocalObjectReference `json:"frontProxyRef,omitempty"`
45+
}
46+
47+
// KubeconfigStatus defines the observed state of Kubeconfig
48+
type KubeconfigStatus struct {
49+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
50+
// Important: Run "make" to regenerate code after modifying this file
51+
}
52+
53+
// +kubebuilder:object:root=true
54+
// +kubebuilder:subresource:status
55+
56+
// Kubeconfig is the Schema for the kubeconfigs API
57+
type Kubeconfig struct {
58+
metav1.TypeMeta `json:",inline"`
59+
metav1.ObjectMeta `json:"metadata,omitempty"`
60+
61+
Spec KubeconfigSpec `json:"spec,omitempty"`
62+
Status KubeconfigStatus `json:"status,omitempty"`
63+
}
64+
65+
// +kubebuilder:object:root=true
66+
67+
// KubeconfigList contains a list of Kubeconfig
68+
type KubeconfigList struct {
69+
metav1.TypeMeta `json:",inline"`
70+
metav1.ListMeta `json:"metadata,omitempty"`
71+
Items []Kubeconfig `json:"items"`
72+
}
73+
74+
func init() {
75+
SchemeBuilder.Register(&Kubeconfig{}, &KubeconfigList{})
76+
}

0 commit comments

Comments
 (0)