Skip to content

Commit

Permalink
Add TLS Support to barbican operator
Browse files Browse the repository at this point in the history
  • Loading branch information
vakwetu authored and d34dh0r53 committed Jan 12, 2024
1 parent 68675ce commit 755ef46
Show file tree
Hide file tree
Showing 34 changed files with 731 additions and 56 deletions.
30 changes: 30 additions & 0 deletions api/bases/barbican.openstack.org_barbicanapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,36 @@ spec:
simpleCryptoBackendKEKSecret:
description: Secret containing SimpleCrypto KEK
type: string
tls:
description: TLS - Parameters related to the TLS
properties:
api:
description: API tls type which encapsulates for API services
properties:
internal:
description: Internal GenericService - holds the secret for
the internal endpoint
properties:
secretName:
description: SecretName - holding the cert, key for the
service
type: string
type: object
public:
description: Public GenericService - holds the secret for
the public endpoint
properties:
secretName:
description: SecretName - holding the cert, key for the
service
type: string
type: object
type: object
caBundleSecretName:
description: CaBundleSecretName - holding the CA certs in a pre-created
bundle file
type: string
type: object
transportURLSecret:
description: TransportURLSecret - Secret containing RabbitMQ transportURL
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ spec:
simpleCryptoBackendKEKSecret:
description: Secret containing SimpleCrypto KEK
type: string
tls:
description: TLS - Parameters related to the TLS
properties:
caBundleSecretName:
description: CaBundleSecretName - holding the CA certs in a pre-created
bundle file
type: string
type: object
transportURLSecret:
type: string
required:
Expand Down
30 changes: 30 additions & 0 deletions api/bases/barbican.openstack.org_barbicans.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,36 @@ spec:
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
tls:
description: TLS - Parameters related to the TLS
properties:
api:
description: API tls type which encapsulates for API services
properties:
internal:
description: Internal GenericService - holds the secret
for the internal endpoint
properties:
secretName:
description: SecretName - holding the cert, key for
the service
type: string
type: object
public:
description: Public GenericService - holds the secret
for the public endpoint
properties:
secretName:
description: SecretName - holding the cert, key for
the service
type: string
type: object
type: object
caBundleSecretName:
description: CaBundleSecretName - holding the CA certs in
a pre-created bundle file
type: string
type: object
required:
- containerImage
type: object
Expand Down
8 changes: 8 additions & 0 deletions api/bases/barbican.openstack.org_barbicanworkers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,14 @@ spec:
simpleCryptoBackendKEKSecret:
description: Secret containing SimpleCrypto KEK
type: string
tls:
description: TLS - Parameters related to the TLS
properties:
caBundleSecretName:
description: CaBundleSecretName - holding the CA certs in a pre-created
bundle file
type: string
type: object
transportURLSecret:
type: string
required:
Expand Down
2 changes: 1 addition & 1 deletion api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.19
require (
github.com/onsi/ginkgo/v2 v2.13.2
github.com/onsi/gomega v1.30.0
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240106101723-5f7aa263457f
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240110131857-e70e1dec4d14
k8s.io/api v0.26.12
k8s.io/apimachinery v0.27.1
k8s.io/client-go v0.26.12
Expand Down
4 changes: 2 additions & 2 deletions api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ github.com/onsi/ginkgo/v2 v2.13.2 h1:Bi2gGVkfn6gQcjNjZJVO8Gf0FHzMPf2phUei9tejVMs
github.com/onsi/ginkgo/v2 v2.13.2/go.mod h1:XStQ8QcGwLyF4HdfcZB8SFOS/MWCgDuXMSBe6zrvLgM=
github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8=
github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240106101723-5f7aa263457f h1:ifW2n0TkrS1Wa58DK/N+zAKdGH5XQh4Llk/hefsXzN8=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240106101723-5f7aa263457f/go.mod h1:ov4lAbniNUsLqZCBp1RTixpqXc8JlzA5B+yTcCkJXQg=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240110131857-e70e1dec4d14 h1:8batipIElAHscbsVUJz8w/2NOvu+pRi8ixF1XUP6WiQ=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240110131857-e70e1dec4d14/go.mod h1:ov4lAbniNUsLqZCBp1RTixpqXc8JlzA5B+yTcCkJXQg=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/barbicanapi_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1beta1
import (
"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -34,6 +35,11 @@ type BarbicanAPITemplate struct {

// Override, provides the ability to override the generated manifest of several child resources.
Override APIOverrideSpec `json:"override,omitempty"`

// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
// TLS - Parameters related to the TLS
TLS tls.API `json:"tls,omitempty"`
}

// APIOverrideSpec to override the generated manifest of several child resources.
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/barbicankeystonelistener_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1beta1

import (
"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -37,6 +38,11 @@ type BarbicanKeystoneListenerSpec struct {
DatabaseHostname string `json:"databaseHostname"`

TransportURLSecret string `json:"transportURLSecret,omitempty"`

// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
// TLS - Parameters related to the TLS
TLS tls.Ca `json:"tls,omitempty"`
}

// BarbicanKeystoneListenerStatus defines the observed state of BarbicanKeystoneListener
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/barbicanworker_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1beta1

import (
"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -37,6 +38,11 @@ type BarbicanWorkerSpec struct {
DatabaseHostname string `json:"databaseHostname"`

TransportURLSecret string `json:"transportURLSecret,omitempty"`

// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
// TLS - Parameters related to the TLS
TLS tls.Ca `json:"tls,omitempty"`
}

// BarbicanWorkerStatus defines the observed state of BarbicanWorker
Expand Down
3 changes: 3 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config/certmanager/kustomizeconfig.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This configuration is for teaching kustomize how to update name ref and var substitution
# This configuration is for teaching kustomize how to update name ref and var substitution
nameReference:
- kind: Issuer
group: cert-manager.io
Expand Down
30 changes: 30 additions & 0 deletions config/crd/bases/barbican.openstack.org_barbicanapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,36 @@ spec:
simpleCryptoBackendKEKSecret:
description: Secret containing SimpleCrypto KEK
type: string
tls:
description: TLS - Parameters related to the TLS
properties:
api:
description: API tls type which encapsulates for API services
properties:
internal:
description: Internal GenericService - holds the secret for
the internal endpoint
properties:
secretName:
description: SecretName - holding the cert, key for the
service
type: string
type: object
public:
description: Public GenericService - holds the secret for
the public endpoint
properties:
secretName:
description: SecretName - holding the cert, key for the
service
type: string
type: object
type: object
caBundleSecretName:
description: CaBundleSecretName - holding the CA certs in a pre-created
bundle file
type: string
type: object
transportURLSecret:
description: TransportURLSecret - Secret containing RabbitMQ transportURL
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ spec:
simpleCryptoBackendKEKSecret:
description: Secret containing SimpleCrypto KEK
type: string
tls:
description: TLS - Parameters related to the TLS
properties:
caBundleSecretName:
description: CaBundleSecretName - holding the CA certs in a pre-created
bundle file
type: string
type: object
transportURLSecret:
type: string
required:
Expand Down
30 changes: 30 additions & 0 deletions config/crd/bases/barbican.openstack.org_barbicans.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,36 @@ spec:
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
tls:
description: TLS - Parameters related to the TLS
properties:
api:
description: API tls type which encapsulates for API services
properties:
internal:
description: Internal GenericService - holds the secret
for the internal endpoint
properties:
secretName:
description: SecretName - holding the cert, key for
the service
type: string
type: object
public:
description: Public GenericService - holds the secret
for the public endpoint
properties:
secretName:
description: SecretName - holding the cert, key for
the service
type: string
type: object
type: object
caBundleSecretName:
description: CaBundleSecretName - holding the CA certs in
a pre-created bundle file
type: string
type: object
required:
- containerImage
type: object
Expand Down
8 changes: 8 additions & 0 deletions config/crd/bases/barbican.openstack.org_barbicanworkers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,14 @@ spec:
simpleCryptoBackendKEKSecret:
description: Secret containing SimpleCrypto KEK
type: string
tls:
description: TLS - Parameters related to the TLS
properties:
caBundleSecretName:
description: CaBundleSecretName - holding the CA certs in a pre-created
bundle file
type: string
type: object
transportURLSecret:
type: string
required:
Expand Down
1 change: 0 additions & 1 deletion config/default/manager_default_images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ spec:
value: quay.io/podified-antelope-centos9/openstack-barbican-worker:current-podified
- name: RELATED_IMAGE_BARBICAN_KEYSTONE_LISTENER_IMAGE_URL_DEFAULT
value: quay.io/podified-antelope-centos9/openstack-barbican-keystone-listener:current-podified

Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,28 @@ spec:
displayName: Barbican API
kind: BarbicanAPI
name: barbicanapis.barbican.openstack.org
specDescriptors:
- description: TLS - Parameters related to the TLS
displayName: TLS
path: tls
version: v1beta1
- description: Barbican is the Schema for the barbicans API
displayName: Barbican
kind: Barbican
name: barbicans.barbican.openstack.org
specDescriptors:
- description: TLS - Parameters related to the TLS
displayName: TLS
path: barbicanAPI.tls
version: v1beta1
- description: BarbicanWorker is the Schema for the barbicanworkers API
displayName: Barbican Worker
kind: BarbicanWorker
name: barbicanworkers.barbican.openstack.org
specDescriptors:
- description: TLS - Parameters related to the TLS
displayName: TLS
path: tls
version: v1beta1
description: Barbican Operator
displayName: Barbican Operator
Expand Down
23 changes: 23 additions & 0 deletions controllers/barbican_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,27 @@ func (r *BarbicanReconciler) reconcileDelete(ctx context.Context, instance *barb
return ctrl.Result{}, nil
}

// fields to index to reconcile when change
const (
passwordSecretField = ".spec.secret"
caBundleSecretNameField = ".spec.tls.caBundleSecretName"
tlsAPIInternalField = ".spec.tls.api.internal.secretName"
tlsAPIPublicField = ".spec.tls.api.public.secretName"
)

var (
commonWatchFields = []string{
passwordSecretField,
caBundleSecretNameField,
}
apinWatchFields = []string{
passwordSecretField,
caBundleSecretNameField,
tlsAPIInternalField,
tlsAPIPublicField,
}
)

// SetupWithManager sets up the controller with the Manager.
func (r *BarbicanReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
Expand Down Expand Up @@ -623,6 +644,7 @@ func (r *BarbicanReconciler) workerDeploymentCreateOrUpdate(ctx context.Context,
BarbicanWorkerTemplate: instance.Spec.BarbicanWorker,
DatabaseHostname: instance.Status.DatabaseHostname,
TransportURLSecret: instance.Status.TransportURLSecret,
TLS: instance.Spec.BarbicanAPI.TLS.Ca,
}

deployment := &barbicanv1beta1.BarbicanWorker{
Expand Down Expand Up @@ -660,6 +682,7 @@ func (r *BarbicanReconciler) keystoneListenerDeploymentCreateOrUpdate(ctx contex
BarbicanKeystoneListenerTemplate: instance.Spec.BarbicanKeystoneListener,
DatabaseHostname: instance.Status.DatabaseHostname,
TransportURLSecret: instance.Status.TransportURLSecret,
TLS: instance.Spec.BarbicanAPI.TLS.Ca,
}

deployment := &barbicanv1beta1.BarbicanKeystoneListener{
Expand Down
Loading

0 comments on commit 755ef46

Please sign in to comment.