mirror of
https://github.com/1Password/onepassword-operator.git
synced 2025-10-22 07:28:06 +00:00
Extract setting context namespace to standalone function SetContextNamespace
This commit is contained in:
@@ -14,10 +14,6 @@
|
|||||||
# pairs:
|
# pairs:
|
||||||
# someName: someValue
|
# someName: someValue
|
||||||
|
|
||||||
resources:
|
|
||||||
- ../crd
|
|
||||||
- ../rbac
|
|
||||||
- ../manager
|
|
||||||
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
|
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
|
||||||
# crd/kustomization.yaml
|
# crd/kustomization.yaml
|
||||||
#- ../webhook
|
#- ../webhook
|
||||||
@@ -26,6 +22,10 @@ resources:
|
|||||||
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
|
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
|
||||||
#- ../prometheus
|
#- ../prometheus
|
||||||
# [METRICS] Expose the controller manager metrics service.
|
# [METRICS] Expose the controller manager metrics service.
|
||||||
|
resources:
|
||||||
|
- ../crd
|
||||||
|
- ../rbac
|
||||||
|
- ../manager
|
||||||
- metrics_service.yaml
|
- metrics_service.yaml
|
||||||
# [NETWORK POLICY] Protect the /metrics endpoint and Webhook Server with NetworkPolicy.
|
# [NETWORK POLICY] Protect the /metrics endpoint and Webhook Server with NetworkPolicy.
|
||||||
# Only Pod(s) running a namespace labeled with 'metrics: enabled' will be able to gather the metrics.
|
# Only Pod(s) running a namespace labeled with 'metrics: enabled' will be able to gather the metrics.
|
||||||
@@ -34,201 +34,12 @@ resources:
|
|||||||
#- ../network-policy
|
#- ../network-policy
|
||||||
|
|
||||||
# Uncomment the patches line if you enable Metrics
|
# Uncomment the patches line if you enable Metrics
|
||||||
patches:
|
|
||||||
# [METRICS] The following patch will enable the metrics endpoint using HTTPS and the port :8443.
|
# [METRICS] The following patch will enable the metrics endpoint using HTTPS and the port :8443.
|
||||||
# More info: https://book.kubebuilder.io/reference/metrics
|
# More info: https://book.kubebuilder.io/reference/metrics
|
||||||
|
patches:
|
||||||
- path: manager_metrics_patch.yaml
|
- path: manager_metrics_patch.yaml
|
||||||
target:
|
target:
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
# Uncomment the patches line if you enable Metrics and CertManager
|
kind: Kustomization
|
||||||
# [METRICS-WITH-CERTS] To enable metrics protected with certManager, uncomment the following line.
|
namespace: default
|
||||||
# This patch will protect the metrics with certManager self-signed certs.
|
|
||||||
#- path: cert_metrics_manager_patch.yaml
|
|
||||||
# target:
|
|
||||||
# kind: Deployment
|
|
||||||
|
|
||||||
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
|
|
||||||
# crd/kustomization.yaml
|
|
||||||
#- path: manager_webhook_patch.yaml
|
|
||||||
# target:
|
|
||||||
# kind: Deployment
|
|
||||||
|
|
||||||
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix.
|
|
||||||
# Uncomment the following replacements to add the cert-manager CA injection annotations
|
|
||||||
#replacements:
|
|
||||||
# - source: # Uncomment the following block to enable certificates for metrics
|
|
||||||
# kind: Service
|
|
||||||
# version: v1
|
|
||||||
# name: controller-manager-metrics-service
|
|
||||||
# fieldPath: metadata.name
|
|
||||||
# targets:
|
|
||||||
# - select:
|
|
||||||
# kind: Certificate
|
|
||||||
# group: cert-manager.io
|
|
||||||
# version: v1
|
|
||||||
# name: metrics-certs
|
|
||||||
# fieldPaths:
|
|
||||||
# - spec.dnsNames.0
|
|
||||||
# - spec.dnsNames.1
|
|
||||||
# options:
|
|
||||||
# delimiter: '.'
|
|
||||||
# index: 0
|
|
||||||
# create: true
|
|
||||||
# - select: # Uncomment the following to set the Service name for TLS config in Prometheus ServiceMonitor
|
|
||||||
# kind: ServiceMonitor
|
|
||||||
# group: monitoring.coreos.com
|
|
||||||
# version: v1
|
|
||||||
# name: controller-manager-metrics-monitor
|
|
||||||
# fieldPaths:
|
|
||||||
# - spec.endpoints.0.tlsConfig.serverName
|
|
||||||
# options:
|
|
||||||
# delimiter: '.'
|
|
||||||
# index: 0
|
|
||||||
# create: true
|
|
||||||
#
|
|
||||||
# - source:
|
|
||||||
# kind: Service
|
|
||||||
# version: v1
|
|
||||||
# name: controller-manager-metrics-service
|
|
||||||
# fieldPath: metadata.namespace
|
|
||||||
# targets:
|
|
||||||
# - select:
|
|
||||||
# kind: Certificate
|
|
||||||
# group: cert-manager.io
|
|
||||||
# version: v1
|
|
||||||
# name: metrics-certs
|
|
||||||
# fieldPaths:
|
|
||||||
# - spec.dnsNames.0
|
|
||||||
# - spec.dnsNames.1
|
|
||||||
# options:
|
|
||||||
# delimiter: '.'
|
|
||||||
# index: 1
|
|
||||||
# create: true
|
|
||||||
# - select: # Uncomment the following to set the Service namespace for TLS in Prometheus ServiceMonitor
|
|
||||||
# kind: ServiceMonitor
|
|
||||||
# group: monitoring.coreos.com
|
|
||||||
# version: v1
|
|
||||||
# name: controller-manager-metrics-monitor
|
|
||||||
# fieldPaths:
|
|
||||||
# - spec.endpoints.0.tlsConfig.serverName
|
|
||||||
# options:
|
|
||||||
# delimiter: '.'
|
|
||||||
# index: 1
|
|
||||||
# create: true
|
|
||||||
#
|
|
||||||
# - source: # Uncomment the following block if you have any webhook
|
|
||||||
# kind: Service
|
|
||||||
# version: v1
|
|
||||||
# name: webhook-service
|
|
||||||
# fieldPath: .metadata.name # Name of the service
|
|
||||||
# targets:
|
|
||||||
# - select:
|
|
||||||
# kind: Certificate
|
|
||||||
# group: cert-manager.io
|
|
||||||
# version: v1
|
|
||||||
# name: serving-cert
|
|
||||||
# fieldPaths:
|
|
||||||
# - .spec.dnsNames.0
|
|
||||||
# - .spec.dnsNames.1
|
|
||||||
# options:
|
|
||||||
# delimiter: '.'
|
|
||||||
# index: 0
|
|
||||||
# create: true
|
|
||||||
# - source:
|
|
||||||
# kind: Service
|
|
||||||
# version: v1
|
|
||||||
# name: webhook-service
|
|
||||||
# fieldPath: .metadata.namespace # Namespace of the service
|
|
||||||
# targets:
|
|
||||||
# - select:
|
|
||||||
# kind: Certificate
|
|
||||||
# group: cert-manager.io
|
|
||||||
# version: v1
|
|
||||||
# name: serving-cert
|
|
||||||
# fieldPaths:
|
|
||||||
# - .spec.dnsNames.0
|
|
||||||
# - .spec.dnsNames.1
|
|
||||||
# options:
|
|
||||||
# delimiter: '.'
|
|
||||||
# index: 1
|
|
||||||
# create: true
|
|
||||||
#
|
|
||||||
# - source: # Uncomment the following block if you have a ValidatingWebhook (--programmatic-validation)
|
|
||||||
# kind: Certificate
|
|
||||||
# group: cert-manager.io
|
|
||||||
# version: v1
|
|
||||||
# name: serving-cert # This name should match the one in certificate.yaml
|
|
||||||
# fieldPath: .metadata.namespace # Namespace of the certificate CR
|
|
||||||
# targets:
|
|
||||||
# - select:
|
|
||||||
# kind: ValidatingWebhookConfiguration
|
|
||||||
# fieldPaths:
|
|
||||||
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
|
|
||||||
# options:
|
|
||||||
# delimiter: '/'
|
|
||||||
# index: 0
|
|
||||||
# create: true
|
|
||||||
# - source:
|
|
||||||
# kind: Certificate
|
|
||||||
# group: cert-manager.io
|
|
||||||
# version: v1
|
|
||||||
# name: serving-cert
|
|
||||||
# fieldPath: .metadata.name
|
|
||||||
# targets:
|
|
||||||
# - select:
|
|
||||||
# kind: ValidatingWebhookConfiguration
|
|
||||||
# fieldPaths:
|
|
||||||
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
|
|
||||||
# options:
|
|
||||||
# delimiter: '/'
|
|
||||||
# index: 1
|
|
||||||
# create: true
|
|
||||||
#
|
|
||||||
# - source: # Uncomment the following block if you have a DefaultingWebhook (--defaulting )
|
|
||||||
# kind: Certificate
|
|
||||||
# group: cert-manager.io
|
|
||||||
# version: v1
|
|
||||||
# name: serving-cert
|
|
||||||
# fieldPath: .metadata.namespace # Namespace of the certificate CR
|
|
||||||
# targets:
|
|
||||||
# - select:
|
|
||||||
# kind: MutatingWebhookConfiguration
|
|
||||||
# fieldPaths:
|
|
||||||
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
|
|
||||||
# options:
|
|
||||||
# delimiter: '/'
|
|
||||||
# index: 0
|
|
||||||
# create: true
|
|
||||||
# - source:
|
|
||||||
# kind: Certificate
|
|
||||||
# group: cert-manager.io
|
|
||||||
# version: v1
|
|
||||||
# name: serving-cert
|
|
||||||
# fieldPath: .metadata.name
|
|
||||||
# targets:
|
|
||||||
# - select:
|
|
||||||
# kind: MutatingWebhookConfiguration
|
|
||||||
# fieldPaths:
|
|
||||||
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
|
|
||||||
# options:
|
|
||||||
# delimiter: '/'
|
|
||||||
# index: 1
|
|
||||||
# create: true
|
|
||||||
#
|
|
||||||
# - source: # Uncomment the following block if you have a ConversionWebhook (--conversion)
|
|
||||||
# kind: Certificate
|
|
||||||
# group: cert-manager.io
|
|
||||||
# version: v1
|
|
||||||
# name: serving-cert
|
|
||||||
# fieldPath: .metadata.namespace # Namespace of the certificate CR
|
|
||||||
# targets: # Do not remove or uncomment the following scaffold marker; required to generate code for target CRD.
|
|
||||||
# +kubebuilder:scaffold:crdkustomizecainjectionns
|
|
||||||
# - source:
|
|
||||||
# kind: Certificate
|
|
||||||
# group: cert-manager.io
|
|
||||||
# version: v1
|
|
||||||
# name: serving-cert
|
|
||||||
# fieldPath: .metadata.name
|
|
||||||
# targets: # Do not remove or uncomment the following scaffold marker; required to generate code for target CRD.
|
|
||||||
# +kubebuilder:scaffold:crdkustomizecainjectionname
|
|
||||||
|
@@ -22,10 +22,8 @@ const (
|
|||||||
|
|
||||||
var _ = Describe("Onepassword Operator e2e", Ordered, func() {
|
var _ = Describe("Onepassword Operator e2e", Ordered, func() {
|
||||||
BeforeAll(func() {
|
BeforeAll(func() {
|
||||||
By("Set namespace to default")
|
kube.SetContextNamespace("default")
|
||||||
_, _ = system.Run("kubectl", "config", "set-context", "--current", "--namespace=default")
|
|
||||||
|
|
||||||
By("Build the operator image")
|
|
||||||
operator.BuildOperatorImage()
|
operator.BuildOperatorImage()
|
||||||
kind.LoadImageToKind(operatorImageName)
|
kind.LoadImageToKind(operatorImageName)
|
||||||
|
|
||||||
|
@@ -48,6 +48,12 @@ func DeleteSecret(name string) {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetContextNamespace(namespace string) {
|
||||||
|
By("Set namespace to " + namespace)
|
||||||
|
_, err := system.Run("kubectl", "config", "set-context", "--current", "--namespace="+namespace)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
}
|
||||||
|
|
||||||
// PatchOperatorToUseServiceAccount sets `OP_SERVICE_ACCOUNT_TOKEN` env variable
|
// PatchOperatorToUseServiceAccount sets `OP_SERVICE_ACCOUNT_TOKEN` env variable
|
||||||
var PatchOperatorToUseServiceAccount = WithOperatorRestart(func() {
|
var PatchOperatorToUseServiceAccount = WithOperatorRestart(func() {
|
||||||
By("patching the operator deployment with service account token")
|
By("patching the operator deployment with service account token")
|
||||||
|
Reference in New Issue
Block a user