Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat: k8 operator namespace installation
Sheen Capadngan39f71f9488c5
diff --git a/docs/integrations/platforms/kubernetes.mdx b/docs/integrations/platforms/kubernetes.mdxindex 8ea24d65fd..8f42b4dde9 100644--- a/docs/integrations/platforms/kubernetes.mdx+++ b/docs/integrations/platforms/kubernetes.mdx@@ -41,6 +41,30 @@ The operator can be install via [Helm](https://helm.sh) or [kubectl](https://githelm install --generate-name infisical-helm-charts/secrets-operator --version=0.1.4 --set controllerManager.manager.image.tag=v0.2.0```+ **Namespace-scoped Installation**++ The operator can be configured to watch and manage secrets in a specific namespace instead of having cluster-wide access.++ ```bash+ helm install operator infisical-helm-charts/secrets-operator \+ --namespace your-namespace \+ --set scopedNamespace=your-namespace \+ --set scopedRBAC=true+ ```++ When scoped to a namespace, the operator will:++ - Only watch InfisicalSecrets in the specified namespace+ - Only create/update Kubernetes secrets in that namespace+ - Only access deployments in that namespace++ The default configuration gives cluster-wide access:++ ```yaml+ scopedNamespace: "" # Empty for cluster-wide access+ scopedRBAC: false # Cluster-wide permissions+ ```+</Tab><Tab title="Kubectl">For production deployments, it is highly recommended to set the version of the Kubernetes operator manually instead of pointing to the latest version.diff --git a/helm-charts/secrets-operator/Chart.yaml b/helm-charts/secrets-operator/Chart.yamlindex 8ff17cdaad..f212ce4eb2 100644--- a/helm-charts/secrets-operator/Chart.yaml+++ b/helm-charts/secrets-operator/Chart.yaml@@ -13,9 +13,9 @@ type: application# This is the chart version. This version number should be incremented each time you make changes# to the chart and its templates, including the app version.# Versions are expected to follow Semantic Versioning (https://semver.org/)-version: v0.7.4+version: v0.7.5# This is the version number of the application being deployed. This version number should be# incremented each time you make changes to the application. Versions are not expected to# follow Semantic Versioning. They should reflect the version the application is using.# It is recommended to use it with quotes.-appVersion: "v0.7.4"+appVersion: "v0.7.5"diff --git a/helm-charts/secrets-operator/templates/deployment.yaml b/helm-charts/secrets-operator/templates/deployment.yamlindex ec02df12d5..e67db7b3fe 100644--- a/helm-charts/secrets-operator/templates/deployment.yaml+++ b/helm-charts/secrets-operator/templates/deployment.yaml@@ -54,7 +54,11 @@ spec:10 }}securityContext: {{- toYaml .Values.controllerManager.kubeRbacProxy.containerSecurityContext| nindent 10 }}- - args: {{- toYaml .Values.controllerManager.manager.args | nindent 8 }}+ - args:+ {{- toYaml .Values.controllerManager.manager.args | nindent 8 }}+ {{- if and .Values.scopedNamespace .Values.scopedRBAC }}+ - --namespace={{ .Values.scopedNamespace }}+ {{- end }}command:- /managerenv:diff --git a/helm-charts/secrets-operator/templates/manager-rbac.yaml b/helm-charts/secrets-operator/templates/manager-rbac.yamlindex ca6fd36e13..33f00198fd 100644--- a/helm-charts/secrets-operator/templates/manager-rbac.yaml+++ b/helm-charts/secrets-operator/templates/manager-rbac.yaml@@ -1,7 +1,14 @@apiVersion: rbac.authorization.k8s.io/v1+{{- if and .Values.scopedNamespace .Values.scopedRBAC }}+kind: Role+{{- else }}kind: ClusterRole+{{- end }}metadata:name: {{ include "secrets-operator.fullname" . }}-manager-role+ {{- if and .Values.scopedNamespace .Values.scopedRBAC }}+ namespace: {{ .Values.scopedNamespace | quote }}+ {{- end }}labels:{{- include "secrets-operator.labels" . | nindent 4 }}rules:@@ -72,9 +79,16 @@ rules:- update---apiVersion: rbac.authorization.k8s.io/v1+{{- if and .Values.scopedNamespace .Values.scopedRBAC }}+kind: RoleBinding+{{- else }}kind: ClusterRoleBinding+{{- end }}metadata:name: {{ include "secrets-operator.fullname" . }}-manager-rolebinding+ {{- if and .Values.scopedNamespace .Values.scopedRBAC }}+ namespace: {{ .Values.scopedNamespace | quote }}+ {{- end }}labels:app.kubernetes.io/component: rbacapp.kubernetes.io/created-by: k8-operator@@ -82,7 +96,11 @@ metadata:{{- include "secrets-operator.labels" . | nindent 4 }}roleRef:apiGroup: rbac.authorization.k8s.io+ {{- if and .Values.scopedNamespace .Values.scopedRBAC }}+ kind: Role+ {{- else }}kind: ClusterRole+ {{- end }}name: '{{ include "secrets-operator.fullname" . }}-manager-role'subjects:- kind: ServiceAccountdiff --git a/helm-charts/secrets-operator/values.yaml b/helm-charts/secrets-operator/values.yamlindex c2ad28f2b2..fcd3739e8e 100644--- a/helm-charts/secrets-operator/values.yaml+++ b/helm-charts/secrets-operator/values.yaml@@ -1,15 +1,15 @@controllerManager:kubeRbacProxy:args:- - --secure-listen-address=0.0.0.0:8443- - --upstream=http://127.0.0.1:8080/- - --logtostderr=true- - --v=0+ - --secure-listen-address=0.0.0.0:8443+ - --upstream=http://127.0.0.1:8080/+ - --logtostderr=true+ - --v=0containerSecurityContext:allowPrivilegeEscalation: falsecapabilities:drop:- - ALL+ - ALLimage:repository: gcr.io/kubebuilder/kube-rbac-proxytag: v0.15.0@@ -22,14 +22,14 @@ controllerManager:memory: 64Mimanager:args:- - --health-probe-bind-address=:8081- - --metrics-bind-address=127.0.0.1:8080- - --leader-elect+ - --health-probe-bind-address=:8081+ - --metrics-bind-address=127.0.0.1:8080+ - --leader-electcontainerSecurityContext:allowPrivilegeEscalation: falsecapabilities:drop:- - ALL+ - ALLimage:repository: infisical/kubernetes-operatortag: v0.7.4@@ -46,10 +46,12 @@ controllerManager:nodeSelector: {}tolerations: []kubernetesClusterDomain: cluster.local+scopedNamespace: ""+scopedRBAC: falsemetricsService:ports:- - name: https- port: 8443- protocol: TCP- targetPort: https+ - name: https+ port: 8443+ protocol: TCP+ targetPort: httpstype: ClusterIPdiff --git a/k8-operator/main.go b/k8-operator/main.goindex 50c0cda004..4fb64c7f44 100644--- a/k8-operator/main.go+++ b/k8-operator/main.go@@ -36,8 +36,10 @@ func main() {var metricsAddr stringvar enableLeaderElection boolvar probeAddr string+ var namespace stringflag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")+ flag.StringVar(&namespace, "namespace", "", "Watch InfisicalSecrets scoped in the provided namespace only")flag.BoolVar(&enableLeaderElection, "leader-elect", false,"Enable leader election for controller manager. "+"Enabling this will ensure there is only one active controller manager.")@@ -49,7 +51,7 @@ func main() {ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))- mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{+ ctrlOpts := ctrl.Options{Scheme: scheme,MetricsBindAddress: metricsAddr,Port: 9443,@@ -67,7 +69,13 @@ func main() {// if you are doing or is intended to do any operation such as perform cleanups// after the manager stops then its usage might be unsafe.// LeaderElectionReleaseOnCancel: true,- })+ }++ if namespace != "" {+ ctrlOpts.Namespace = namespace+ }++ mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrlOpts)if err != nil {setupLog.Error(err, "unable to start manager")os.Exit(1)