Skip to content

Commit

Permalink
Make OS CCM NoOp
Browse files Browse the repository at this point in the history
  • Loading branch information
s3rj1k committed Jan 17, 2025
1 parent acc4f83 commit 8e396c6
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 243 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 OpenStack
ProviderOpenStackName = "cluster-api-provider-openstack"
// Provider K0smotron
ProviderK0smotronName = "k0smotron"
// Provider Sveltos
Expand Down
2 changes: 0 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
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"
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 @@ -66,7 +65,6 @@ func init() {
utilruntime.Must(sourcev1.AddToScheme(scheme))
utilruntime.Must(hcv2.AddToScheme(scheme))
utilruntime.Must(sveltosv1beta1.AddToScheme(scheme))
utilruntime.Must(capo.AddToScheme(scheme))
// +kubebuilder:scaffold:scheme
}

Expand Down
71 changes: 71 additions & 0 deletions config/dev/openstack-credentials.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,74 @@ spec:
kind: Secret
name: openstack-cloud-config
namespace: ${NAMESPACE}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: openstack-cloud-config-resource-template
namespace: ${NAMESPACE}
annotations:
projectsveltos.io/template: "true"
data:
configmap.yaml: |
{{- $$cluster := .InfrastructureProvider -}}
{{- $$identity := (getResource "InfrastructureProviderIdentity") -}}
{{- $$clouds := fromYaml (index $$identity "data" "clouds.yaml" | b64dec) -}}
{{- if not $$clouds }}
{{ fail "failed to decode clouds.yaml" }}
{{ end -}}
{{- $$openstack := index $$clouds "clouds" "openstack" -}}
{{- if not (hasKey $$openstack "auth") }}
{{ fail "auth key not found in openstack config" }}
{{- end }}
{{- $$auth := index $$openstack "auth" -}}
{{- $$auth_url := index $$auth "auth_url" -}}
{{- $$app_cred_id := index $$auth "application_credential_id" -}}
{{- $$app_cred_name := index $$auth "application_credential_name" -}}
{{- $$app_cred_secret := index $$auth "application_credential_secret" -}}
{{- $$network_id := $$cluster.status.externalNetwork.id -}}
{{- $$network_name := $$cluster.status.externalNetwork.name -}}
---
apiVersion: v1
kind: Secret
metadata:
name: openstack-cloud-config
namespace: kube-system
type: Opaque
stringData:
cloud.conf: |
[Global]
auth-url="{{ $$auth_url }}"
{{- if $$app_cred_id }}
application-credential-id="{{ $$app_cred_id }}"
{{- end }}
{{- if $$app_cred_name }}
application-credential-name="{{ $$app_cred_name }}"
{{- end }}
{{- if $$app_cred_secret }}
application-credential-secret="{{ $$app_cred_secret }}"
{{- end }}
{{- if and (not $$app_cred_id) (not $$app_cred_secret) }}
username="{{ index $$openstack "username" }}"
password="{{ index $$openstack "password" }}"
{{- end }}
region="{{ index $$openstack "region_name" }}"
[LoadBalancer]
{{- if $$network_id }}
floating-network-id="{{ $$network_id }}"
{{- end }}
[Network]
{{- if $$network_name }}
public-network-name="{{ $$network_name }}"
{{- end }}
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ require (
k8s.io/utils v0.0.0-20241210054802-24370beab758
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/controller-runtime v0.19.4
)

Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,6 @@ sigs.k8s.io/cluster-api v1.9.3 h1:lKWbrXzyNmJh++IcX54ZbAmnO7tZ2wKgds7WvskpiXY=
sigs.k8s.io/cluster-api v1.9.3/go.mod h1:5iojv38PSvOd4cxqu08Un5TQmy2yBkd3+0U7R/e+msk=
sigs.k8s.io/cluster-api-operator v0.15.1 h1:oGEqNE7c1Ieqwso/DwjRVD2b/7wFXIjEKAodlwsO6/Q=
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/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
11 changes: 8 additions & 3 deletions internal/controller/clusterdeployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,21 +422,26 @@ func getProjectTemplateResourceRefs(cred *kcm.Credential) []sveltosv1beta1.Templ
return nil
}

return []sveltosv1beta1.TemplateResourceRef{
refs := []sveltosv1beta1.TemplateResourceRef{
{
Resource: *cred.Spec.IdentityRef,
Identifier: "InfrastructureProviderIdentity",
},
{
}

if !strings.EqualFold(cred.Spec.IdentityRef.Kind, "Secret") {
refs = append(refs, sveltosv1beta1.TemplateResourceRef{
Resource: corev1.ObjectReference{
APIVersion: "v1",
Kind: "Secret",
Namespace: cred.Spec.IdentityRef.Namespace,
Name: cred.Spec.IdentityRef.Name + "-secret",
},
Identifier: "InfrastructureProviderIdentitySecret",
},
})
}

return refs
}

func getProjectPolicyRefs(cred *kcm.Credential) []sveltosv1beta1.PolicyRef {
Expand Down
6 changes: 3 additions & 3 deletions internal/credspropagation/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type PropagationCfg struct {
SystemNamespace string
}

func applyCCMConfigs(ctx context.Context, kubeconfSecret *corev1.Secret, objects ...client.Object) error {
func applyCCMConfigs(ctx context.Context, kubeconfSecret *corev1.Secret, objects ...client.Object) error { //nolint:unused
clnt, err := makeClientFromSecret(kubeconfSecret)
if err != nil {
return fmt.Errorf("failed to create k8s client: %w", err)
Expand All @@ -54,7 +54,7 @@ func applyCCMConfigs(ctx context.Context, kubeconfSecret *corev1.Secret, objects
return nil
}

func makeSecret(name string, data map[string][]byte) *corev1.Secret {
func makeSecret(name string, data map[string][]byte) *corev1.Secret { //nolint:unused
s := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Expand All @@ -78,7 +78,7 @@ func makeConfigMap(name string, data map[string]string) *corev1.ConfigMap { //no
return c
}

func makeClientFromSecret(kubeconfSecret *corev1.Secret) (client.Client, error) {
func makeClientFromSecret(kubeconfSecret *corev1.Secret) (client.Client, error) { //nolint:unused
scheme := runtime.NewScheme()
if err := clientgoscheme.AddToScheme(scheme); err != nil {
return nil, err
Expand Down
221 changes: 0 additions & 221 deletions internal/credspropagation/openstack.go

This file was deleted.

Loading

0 comments on commit 8e396c6

Please sign in to comment.