Kubernetes Operator that creates Service Endpoints from Secrets
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

migrate to endpointslice

+28 -18
+2 -2
charts/secret-service-operator/Chart.yaml
··· 16 16 # This is the chart version. This version number should be incremented each time you make changes 17 17 # to the chart and its templates, including the app version. 18 18 # Versions are expected to follow Semantic Versioning (https://semver.org/) 19 - version: 0.2.0 19 + version: 0.2.1 20 20 21 21 # This is the version number of the application being deployed. This version number should be 22 22 # incremented each time you make changes to the application. Versions are not expected to 23 23 # follow Semantic Versioning. They should reflect the version the application is using. 24 24 # It is recommended to use it with quotes. 25 - appVersion: "0.2.0" 25 + appVersion: "0.2.1" 26 26 27 27 maintainers: 28 28 - name: evanjarrett
+26 -16
internal/controller/secretservice_controller.go
··· 33 33 "sigs.k8s.io/controller-runtime/pkg/log" 34 34 35 35 appsv1 "github.com/evanjarrett/secret-service-operator/api/v1" 36 + "github.com/google/uuid" 36 37 corev1 "k8s.io/api/core/v1" 38 + discoveryv1 "k8s.io/api/discovery/v1" 37 39 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 38 40 ) 39 41 ··· 127 129 return ctrl.Result{}, err 128 130 } 129 131 130 - // Create or update Endpoints (for ClusterIP service) 131 - endpoints := &corev1.Endpoints{ 132 + httpName := "http" 133 + tcpProtocol := corev1.ProtocolTCP 134 + readyTrue := true 135 + portInt32 := int32(port) 136 + 137 + // Create or update EndpointSlice (modern replacement for Endpoints) 138 + endpointSlice := &discoveryv1.EndpointSlice{ 132 139 ObjectMeta: metav1.ObjectMeta{ 133 - Name: serviceName, 140 + Name: serviceName + "-" + uuid.NewString()[:8], // EndpointSlices need unique names 134 141 Namespace: instance.Namespace, 142 + Labels: map[string]string{ 143 + discoveryv1.LabelServiceName: serviceName, // Required label to associate with Service 144 + }, 135 145 }, 136 - Subsets: []corev1.EndpointSubset{ 146 + AddressType: discoveryv1.AddressTypeIPv4, 147 + Endpoints: []discoveryv1.Endpoint{ 137 148 { 138 - Addresses: []corev1.EndpointAddress{ 139 - { 140 - IP: endpointIP, 141 - }, 142 - }, 143 - Ports: []corev1.EndpointPort{ 144 - { 145 - Name: "http", 146 - Port: int32(port), 147 - Protocol: corev1.ProtocolTCP, 148 - }, 149 + Addresses: []string{endpointIP}, 150 + Conditions: discoveryv1.EndpointConditions{ 151 + Ready: &readyTrue, 149 152 }, 150 153 }, 151 154 }, 155 + Ports: []discoveryv1.EndpointPort{ 156 + { 157 + Name: &httpName, 158 + Port: &portInt32, 159 + Protocol: &tcpProtocol, 160 + }, 161 + }, 152 162 } 153 163 154 - if err := r.CreateOrUpdate(ctx, endpoints, instance); err != nil { 164 + if err := r.CreateOrUpdate(ctx, endpointSlice, instance); err != nil { 155 165 return ctrl.Result{}, err 156 166 } 157 167 }