Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clustermesh: validate service type, and fix deprecated LB annotations #2664

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/clustermesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func newCmdClusterMeshEnableWithHelm() *cobra.Command {

cmd.Flags().BoolVar(&params.EnableExternalWorkloads, "enable-external-workloads", false, "Enable support for external workloads, such as VMs")
cmd.Flags().BoolVar(&params.EnableKVStoreMesh, "enable-kvstoremesh", false, "Enable kvstoremesh, an extension which caches remote cluster information in the local kvstore (Cilium >=1.14 only)")
cmd.Flags().StringVar(&params.ServiceType, "service-type", "", "Type of Kubernetes service to expose control plane { LoadBalancer | NodePort | ClusterIP }")
cmd.Flags().StringVar(&params.ServiceType, "service-type", "", "Type of Kubernetes service to expose control plane { LoadBalancer | NodePort }")

return cmd
}
Expand Down
11 changes: 7 additions & 4 deletions clustermesh/clustermesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -1438,12 +1438,12 @@ func generateEnableHelmValues(params Parameters, flavor k8s.Flavor) (map[string]
if params.ServiceType == "" {
switch flavor.Kind {
case k8s.KindGKE:
log("🔮 Auto-exposing service within GCP VPC (cloud.google.com/load-balancer-type=Internal)")
log("🔮 Auto-exposing service within GCP VPC (networking.gke.io/load-balancer-type=Internal)")
helmVals["clustermesh"].(map[string]interface{})["apiserver"] = map[string]interface{}{
"service": map[string]interface{}{
"type": corev1.ServiceTypeLoadBalancer,
"annotations": map[string]interface{}{
"cloud.google.com/load-balancer-type": "Internal",
"networking.gke.io/load-balancer-type": "Internal",
// Allows cross-region access
"networking.gke.io/internal-load-balancer-allow-global-access": "true",
},
Expand All @@ -1460,12 +1460,12 @@ func generateEnableHelmValues(params Parameters, flavor k8s.Flavor) (map[string]
},
}
case k8s.KindEKS:
log("🔮 Auto-exposing service within AWS VPC (service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0")
log("🔮 Auto-exposing service within AWS VPC (service.beta.kubernetes.io/aws-load-balancer-scheme: internal")
helmVals["clustermesh"].(map[string]interface{})["apiserver"] = map[string]interface{}{
"service": map[string]interface{}{
"type": corev1.ServiceTypeLoadBalancer,
"annotations": map[string]interface{}{
"service.beta.kubernetes.io/aws-load-balancer-internal": "0.0.0.0/0",
"service.beta.kubernetes.io/aws-load-balancer-scheme": "internal",
},
},
}
Expand All @@ -1475,7 +1475,10 @@ func generateEnableHelmValues(params Parameters, flavor k8s.Flavor) (map[string]
} else {
if corev1.ServiceType(params.ServiceType) == corev1.ServiceTypeNodePort {
log("⚠️ Using service type NodePort may fail when nodes are removed from the cluster!")
} else if corev1.ServiceType(params.ServiceType) != corev1.ServiceTypeLoadBalancer {
return nil, fmt.Errorf("service type %q is not valid", params.ServiceType)
}

helmVals["clustermesh"].(map[string]interface{})["apiserver"] = map[string]interface{}{
"service": map[string]interface{}{
"type": params.ServiceType,
Expand Down
Loading