Skip to content

Commit

Permalink
Make vSphere CCM NoOp
Browse files Browse the repository at this point in the history
  • Loading branch information
s3rj1k committed Jan 17, 2025
1 parent 5c40df3 commit acc4f83
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 183 deletions.
2 changes: 0 additions & 2 deletions api/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ type (
const (
// Provider AWS
ProviderAWSName = "cluster-api-provider-aws"
// Provider vSphere
ProviderVSphereName = "cluster-api-provider-vsphere"
// Provider OpenStack
ProviderOpenStackName = "cluster-api-provider-openstack"
// Provider K0smotron
Expand Down
2 changes: 0 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth"
capo "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1"
capv "sigs.k8s.io/cluster-api-provider-vsphere/apis/v1beta1"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
Expand Down Expand Up @@ -67,7 +66,6 @@ func init() {
utilruntime.Must(sourcev1.AddToScheme(scheme))
utilruntime.Must(hcv2.AddToScheme(scheme))
utilruntime.Must(sveltosv1beta1.AddToScheme(scheme))
utilruntime.Must(capv.AddToScheme(scheme))
utilruntime.Must(capo.AddToScheme(scheme))
// +kubebuilder:scaffold:scheme
}
Expand Down
62 changes: 62 additions & 0 deletions config/dev/vsphere-credentials.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,65 @@ spec:
kind: VSphereClusterIdentity
name: vsphere-cluster-identity
namespace: ${NAMESPACE}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: vsphere-cluster-identity-resource-template
namespace: ${NAMESPACE}
annotations:
projectsveltos.io/template: "true"
data:
configmap.yaml: |
{{- $$cluster := .InfrastructureProvider -}}
{{- $$identity := (getResource "InfrastructureProviderIdentity") -}}
{{- $$secret := (getResource "InfrastructureProviderIdentitySecret") -}}
---
apiVersion: v1
kind: Secret
metadata:
name: vsphere-cloud-secret
namespace: kube-system
type: Opaque
data:
{{ printf "%s.username" $$cluster.spec.server }}: {{ index $$secret.data "username" }}
{{ printf "%s.password" $$cluster.spec.server }}: {{ index $$secret.data "password" }}
---
apiVersion: v1
kind: Secret
metadata:
name: vcenter-config-secret
namespace: kube-system
type: Opaque
stringData:
csi-vsphere.conf: |
[Global]
cluster-id = "{{ $$cluster.metadata.name }}"
[VirtualCenter "{{ $$cluster.spec.server }}"]
insecure-flag = "true"
user = "{{ index $$secret.data "username" | b64dec }}"
password = "{{ index $$secret.data "password" | b64dec }}"
port = "443"
datacenters = ${VSPHERE_DATACENTER}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: cloud-config
namespace: kube-system
data:
vsphere.conf: |
global:
insecureFlag: true
port: 443
secretName: vsphere-cloud-secret
secretNamespace: kube-system
labels:
region: k8s-region
zone: k8s-zone
vcenter:
{{ $$cluster.spec.server }}:
datacenters:
- ${VSPHERE_DATACENTER}
server: {{ $$cluster.spec.server }}
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ require (
sigs.k8s.io/cluster-api v1.9.3
sigs.k8s.io/cluster-api-operator v0.15.1
sigs.k8s.io/cluster-api-provider-openstack v0.11.3
sigs.k8s.io/cluster-api-provider-vsphere v1.12.0
sigs.k8s.io/controller-runtime v0.19.4
sigs.k8s.io/yaml v1.4.0
)

require (
Expand Down Expand Up @@ -201,4 +199,5 @@ require (
sigs.k8s.io/kustomize/api v0.18.0 // indirect
sigs.k8s.io/kustomize/kyaml v0.18.1 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.5.0 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,6 @@ sigs.k8s.io/cluster-api-operator v0.15.1 h1:oGEqNE7c1Ieqwso/DwjRVD2b/7wFXIjEKAod
sigs.k8s.io/cluster-api-operator v0.15.1/go.mod h1:0yvW+1BLHcE5/gQfWSin1L4Gj+8wa9y7+vVTXOhUnSg=
sigs.k8s.io/cluster-api-provider-openstack v0.11.3 h1:ZJ3G+m11bgaD227EuFjuFsFC95MRzJm9JbDIte0xwII=
sigs.k8s.io/cluster-api-provider-openstack v0.11.3/go.mod h1:0rH6yksLcuwWK/SoSoCOJi4A0kOSL3qrA+qvDVZ9NjU=
sigs.k8s.io/cluster-api-provider-vsphere v1.12.0 h1:9ze+1JSdLAGiLklsnORvj/vs2XpR9jyVmkT0Dwo1nuc=
sigs.k8s.io/cluster-api-provider-vsphere v1.12.0/go.mod h1:2y9fsZQ3qjT1kL6IXiOUVcyV0n8DLBQGvyPnId9xRzk=
sigs.k8s.io/controller-runtime v0.19.4 h1:SUmheabttt0nx8uJtoII4oIP27BVVvAKFvdvGFwV/Qo=
sigs.k8s.io/controller-runtime v0.19.4/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4=
sigs.k8s.io/gateway-api v1.1.0 h1:DsLDXCi6jR+Xz8/xd0Z1PYl2Pn0TyaFMOPPZIj4inDM=
Expand Down
2 changes: 1 addition & 1 deletion internal/credspropagation/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func makeSecret(name string, data map[string][]byte) *corev1.Secret {
return s
}

func makeConfigMap(name string, data map[string]string) *corev1.ConfigMap {
func makeConfigMap(name string, data map[string]string) *corev1.ConfigMap { //nolint:unused
c := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Expand Down
165 changes: 0 additions & 165 deletions internal/credspropagation/vsphere.go

This file was deleted.

16 changes: 7 additions & 9 deletions internal/providers/vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,16 @@ func (*ProvidervSphere) GetClusterIdentityKinds() []string {
return []string{"VSphereClusterIdentity"}
}

func (p *ProvidervSphere) CredentialPropagationFunc() func(
ctx context.Context,
cfg *credspropagation.PropagationCfg,
l logr.Logger,
func (*ProvidervSphere) CredentialPropagationFunc() func(
_ context.Context,
_ *credspropagation.PropagationCfg,
_ logr.Logger,
) (enabled bool, err error) {
return func(
ctx context.Context,
cfg *credspropagation.PropagationCfg,
l logr.Logger,
_ context.Context,
_ *credspropagation.PropagationCfg,
_ logr.Logger,
) (enabled bool, err error) {
l.Info(p.GetTitleName() + " creds propagation start")
enabled, err = true, credspropagation.PropagateVSphereProviderObjects(ctx, cfg)
return enabled, err
}
}

0 comments on commit acc4f83

Please sign in to comment.