-
Notifications
You must be signed in to change notification settings - Fork 298
/
reconcile.go
62 lines (56 loc) · 1.52 KB
/
reconcile.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package oapi
import (
"fmt"
corev1 "k8s.io/api/core/v1"
apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
"k8s.io/utils/pointer"
)
const (
OpenShiftServicePort = 443
openshiftAPIServerConfigKey = "config.yaml"
configNamespace = "openshift-config"
configHashAnnotation = "openshift-apiserver.hypershift.openshift.io/config-hash"
crdPresentAnnotation = "openshift-apiserver.hypershift.openshift.io/rolebindingrestrictions-present"
)
func ReconcileAPIService(apiService *apiregistrationv1.APIService, svc *corev1.Service, ca *corev1.Secret, group string) {
groupName := fmt.Sprintf("%s.openshift.io", group)
caBundle := ca.Data["ca.crt"]
apiService.Spec = apiregistrationv1.APIServiceSpec{
CABundle: caBundle,
Group: groupName,
Version: "v1",
GroupPriorityMinimum: 9900,
Service: &apiregistrationv1.ServiceReference{
Name: svc.Name,
Namespace: svc.Namespace,
Port: pointer.Int32(443),
},
VersionPriority: 15,
}
}
func ReconcileEndpoints(ep *corev1.Endpoints, clusterIP string) {
ep.Subsets = []corev1.EndpointSubset{
{
Addresses: []corev1.EndpointAddress{
{
IP: clusterIP,
},
},
Ports: []corev1.EndpointPort{
{
Name: "https",
Port: OpenShiftServicePort,
Protocol: corev1.ProtocolTCP,
},
},
},
}
}
func ReconcileClusterService(svc *corev1.Service) {
svc.Spec.Ports = []corev1.ServicePort{
{
Name: "https",
Port: OpenShiftServicePort,
},
}
}