Skip to content

Commit 878f3cb

Browse files
adding POC with Conversions
Signed-off-by: Chris Hein <[email protected]>
1 parent 40f9306 commit 878f3cb

11 files changed

+345
-338
lines changed

examples/config/example.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
apiVersion: controller-runtime.config.sigs.k8s.io/v1alpha1
22
kind: GenericControllerConfiguration
3+
syncPeriod: 24h
34
port: 9443
45
metricsBindAddress: ":8080"
56
leaderElection:

pkg/api/config/conversion.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
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 config
18+
19+
func (*ControllerRuntimeConfiguration) Hub() {}

pkg/api/config/groupversion_info.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
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+
http://www.apache.org/licenses/LICENSE-2.0
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS,
10+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the License for the specific language governing permissions and
12+
limitations under the License.
13+
*/
14+
15+
// Package config provides the Internal ComponentConfig type for configuring
16+
// controller-runtime
17+
// +kubebuilder:object:generate=true
18+
package config

pkg/api/config/types.go

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
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 config
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
22+
configv1alpha1 "k8s.io/component-base/config/v1alpha1"
23+
)
24+
25+
// ControllerConfiguration defines the desired state of GenericControllerConfiguration
26+
type ControllerConfiguration struct {
27+
// SyncPeriod returns the SyncPeriod
28+
// +optional
29+
SyncPeriod *metav1.Duration `json:"syncPeriod,omitempty"`
30+
31+
// LeaderElection returns the LeaderElection config
32+
// +optional
33+
LeaderElection configv1alpha1.LeaderElectionConfiguration `json:"leaderElection,omitempty"`
34+
35+
// Namespace returns the namespace for the controller
36+
// +optional
37+
Namespace string `json:"namespace,omitempty"`
38+
39+
// MetricsBindAddress returns the bind address for the metrics server
40+
// +optional
41+
MetricsBindAddress string `json:"metricsBindAddress,omitempty"`
42+
43+
// MetricsBindAddress returns the bind address for the metrics server
44+
// +optional
45+
Health ControllerHealth `json:"health,omitempty"`
46+
47+
// Port returns the Port for the server
48+
// +optional
49+
Port *int `json:"port,omitempty"`
50+
51+
// Host returns the Host for the server
52+
// +optional
53+
Host string `json:"host,omitempty"`
54+
55+
// CertDir returns the CertDir
56+
// +optional
57+
CertDir string `json:"certDir,omitempty"`
58+
}
59+
60+
// ControllerHealth defines the health configs
61+
type ControllerHealth struct {
62+
// HealthProbeBindAddress returns the bind address for the health probe
63+
// +optional
64+
HealthProbeBindAddress string `json:"healthProbeBindAddress,omitempty"`
65+
66+
// ReadinessEndpointName returns the readiness endpoint name
67+
// +optional
68+
ReadinessEndpointName string `json:"readinessEndpointName,omitempty"`
69+
70+
// LivenessEndpointName returns the liveness endpoint name
71+
// +optional
72+
LivenessEndpointName string `json:"livenessEndpointName,omitempty"`
73+
}
74+
75+
// +kubebuilder:object:root=true
76+
77+
// ControllerRuntimeConfiguration is the Schema for the GenericControllerConfigurations API
78+
type ControllerRuntimeConfiguration struct {
79+
metav1.TypeMeta `json:",inline"`
80+
81+
// ControllerConfiguration returns the contfigurations for controllers
82+
ControllerConfiguration `json:",inline"`
83+
}

pkg/api/config/v1alpha1/componentconfig.go

Lines changed: 0 additions & 205 deletions
This file was deleted.

0 commit comments

Comments
 (0)