-
Notifications
You must be signed in to change notification settings - Fork 65
✨ Single/Own Namespace Install Mode Support #1724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f26be51
cc6f1c4
f8d8874
9190b9d
0e8f7a2
b421152
e39a1f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
## Description | ||
|
||
!!! note | ||
This feature is still in *alpha* the `SingleOwnNamespaceInstallSupport` feature-gate must be enabled to make use of it. | ||
See the instructions below on how to enable it. | ||
|
||
--- | ||
|
||
A component of OLMv0's multi-tenancy feature is its support of four [*installModes*](https://olm.operatorframework.io/docs/advanced-tasks/operator-scoping-with-operatorgroups/#targetnamespaces-and-their-relationship-to-installmodes): | ||
for operator installation: | ||
|
||
- *OwnNamespace*: If supported, the operator can be configured to watch for events in the namespace it is deployed in. | ||
- *SingleNamespace*: If supported, the operator can be configured to watch for events in a single namespace that the operator is not deployed in. | ||
- *MultiNamespace*: If supported, the operator can be configured to watch for events in more than one namespace. | ||
- *AllNamespaces*: If supported, the operator can be configured to watch for events in all namespaces. | ||
|
||
OLMv1 will not attempt multi-tenancy (see [design decisions document](../../project/olmv1_design_decisions.md)) and will think of operators | ||
as globally installed, i.e. in OLMv0 parlance, as installed in *AllNamespaces* mode. However, there are operators that | ||
were intended only for the *SingleNamespace* and *OwnNamespace* install modes. In order to make these operators installable in v1 while they | ||
transition to the new model, v1 is adding support for these two new *installModes*. It should be noted that, in line with v1's no multi-tenancy policy, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed in the separate venue, @joelanford , there is set of use cases, where it is expected for OLMv1 to allow multiple installation of the same operator with different scopes each, on the same cluster. Just want to make sure this PR is an incremental step towards this and not the final decision. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OLMv1 won't directly support multi-tenancy as a first class concept. This PR doesn't change that one way or the other. All this PR does is make it possible to install registry+v1 bundles that support Own/SingleNamespace mode, but not AllNamespace mode. This PR does not preclude multiple installations of the same bundle in different namespaces, so long as the installation of that bundle does not violate OLMv1's single owner policy. One fairly obvious outcome is that bundles that ship CRDs will never be able to be installed twice because CRD names are validated according to their resource name and group. Also of note, the registry+v1 format does not allow for templated names of objects in the bundle, so if a bundle has any cluster-scoped objects, it will only be installable once per cluster. But this is a registry+v1 limitation, not an OLMv1 limitation. In the future, I expect OLMv1 to handle bundle formats that do support arbitrary templating. I can see how this text makes it seem like we're making a blanket statement about one install per cluster, but that is not technically the case. From a practical perspective, I'm guessing >95% of bundles include a cluster-scoped object, which largely makes this sentence true for end users for now. |
||
users will not be able to install the same operator multiple times, and that in future iterations of the registry bundle format will not | ||
include *installModes*. | ||
|
||
## Demos | ||
|
||
### SingleNamespace Install | ||
|
||
[](https://asciinema.org/a/w1IW0xWi1S9cKQFb9jnR07mgh) | ||
|
||
### OwnNamespace Install | ||
|
||
[](https://asciinema.org/a/Rxx6WUwAU016bXFDW74XLcM5i) | ||
|
||
## Enabling the Feature-Gate | ||
|
||
!!! tip | ||
|
||
This guide assumes OLMv1 is already installed. If that is not the case, | ||
you can follow the [getting started](../../getting-started/olmv1_getting_started.md) guide to install OLMv1. | ||
|
||
--- | ||
|
||
Patch the `operator-controller` `Deployment` adding `--feature-gates=SingleOwnNamespaceInstallSupport=true` to the | ||
controller container arguments: | ||
|
||
```terminal title="Enable SingleOwnNamespaceInstallSupport feature-gate" | ||
kubectl patch deployment -n olmv1-system operator-controller-controller-manager --type='json' -p='[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--feature-gates=SingleOwnNamespaceInstallSupport=true"}]' | ||
``` | ||
|
||
Wait for `Deployment` rollout: | ||
|
||
```terminal title="Wait for Deployment rollout" | ||
kubectl rollout status -n olmv1-system deployment/operator-controller-controller-manager | ||
``` | ||
|
||
## Configuring the `ClusterExtension` | ||
|
||
A `ClusterExtension` can be configured to install bundle in `Single-` or `OwnNamespace` mode through the | ||
`olm.operatorframework.io/watch-namespace: <namespace>` annotation. The *installMode* is inferred in the following way: | ||
|
||
- *AllNamespaces*: `<namespace>` is empty, or the annotation is not present | ||
- *OwnNamespace*: `<namespace>` is the install namespace (i.e. `.spec.namespace`) | ||
- *SingleNamespace*: `<namespace>` not the install namespace | ||
|
||
### Examples | ||
|
||
``` terminal title="SingleNamespace install mode example" | ||
kubectl apply -f - <<EOF | ||
apiVersion: olm.operatorframework.io/v1 | ||
kind: ClusterExtension | ||
metadata: | ||
name: argocd | ||
annotations: | ||
olm.operatorframework.io/watch-namespace: argocd-watch | ||
perdasilva marked this conversation as resolved.
Show resolved
Hide resolved
|
||
spec: | ||
namespace: argocd | ||
serviceAccount: | ||
name: argocd-installer | ||
source: | ||
sourceType: Catalog | ||
catalog: | ||
packageName: argocd-operator | ||
version: 0.2.1 # Update to version 0.2.1 | ||
EOF | ||
``` | ||
|
||
``` terminal title="OwnNamespace install mode example" | ||
kubectl apply -f - <<EOF | ||
apiVersion: olm.operatorframework.io/v1 | ||
kind: ClusterExtension | ||
metadata: | ||
name: argocd | ||
annotations: | ||
olm.operatorframework.io/watch-namespace: argocd | ||
spec: | ||
namespace: argocd | ||
serviceAccount: | ||
name: argocd-installer | ||
source: | ||
sourceType: Catalog | ||
catalog: | ||
packageName: argocd-operator | ||
version: 0.2.1 # Update to version 0.2.1 | ||
EOF | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
|
||
# | ||
# Welcome to the OwnNamespace install mode demo | ||
# | ||
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT | ||
|
||
# enable 'SingleOwnNamespaceInstallSupport' feature gate | ||
kubectl patch deployment -n olmv1-system operator-controller-controller-manager --type='json' -p='[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--feature-gates=SingleOwnNamespaceInstallSupport=true"}]' | ||
|
||
# wait for operator-controller to become available | ||
kubectl rollout status -n olmv1-system deployment/operator-controller-controller-manager | ||
|
||
# create install namespace | ||
kubectl create ns argocd-system | ||
|
||
# create installer service account | ||
kubectl create serviceaccount -n argocd-system argocd-installer | ||
|
||
# give installer service account admin privileges (not for production environments) | ||
kubectl create clusterrolebinding argocd-installer-crb --clusterrole=cluster-admin --serviceaccount=argocd-system:argocd-installer | ||
|
||
# install cluster extension in own namespace install mode (watch-namespace == install namespace == argocd-system) | ||
cat ${DEMO_RESOURCE_DIR}/own-namespace-demo.yaml | ||
|
||
# apply cluster extension | ||
kubectl apply -f ${DEMO_RESOURCE_DIR}/own-namespace-demo.yaml | ||
|
||
# wait for cluster extension installation to succeed | ||
kubectl wait --for=condition=Installed clusterextension/argocd-operator --timeout="60s" | ||
|
||
# check argocd-operator controller deployment pod template olm.targetNamespaces annotation | ||
kubectl get deployments -n argocd-system argocd-operator-controller-manager -o jsonpath="{.spec.template.metadata.annotations.olm\.targetNamespaces}" | ||
|
||
# check for argocd-operator rbac in watch namespace | ||
kubectl get roles,rolebindings -n argocd-system -o name | ||
|
||
# get controller service-account name | ||
kubectl get deployments -n argocd-system argocd-operator-controller-manager -o jsonpath="{.spec.template.spec.serviceAccount}" | ||
|
||
# check service account for role binding is the same as controller service-account | ||
rolebinding=$(kubectl get rolebindings -n argocd-system -o name | grep 'argocd-operator' | head -n 1) | ||
kubectl get -n argocd-system $rolebinding -o jsonpath='{.subjects}' | jq .[0] | ||
perdasilva marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: olm.operatorframework.io/v1 | ||
kind: ClusterExtension | ||
metadata: | ||
name: argocd-operator | ||
annotations: | ||
# watch namespace is the same as intall namespace | ||
olm.operatorframework.io/watch-namespace: argocd-system | ||
spec: | ||
namespace: argocd-system | ||
serviceAccount: | ||
name: argocd-installer | ||
source: | ||
sourceType: Catalog | ||
catalog: | ||
packageName: argocd-operator | ||
version: 0.6.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: olm.operatorframework.io/v1 | ||
kind: ClusterExtension | ||
metadata: | ||
name: argocd-operator | ||
annotations: | ||
# watch-namespace is different from install namespace | ||
olm.operatorframework.io/watch-namespace: argocd | ||
camilamacedo86 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
spec: | ||
namespace: argocd-system | ||
serviceAccount: | ||
name: argocd-installer | ||
source: | ||
sourceType: Catalog | ||
catalog: | ||
packageName: argocd-operator | ||
version: 0.6.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
|
||
# | ||
# Welcome to the SingleNamespace install mode demo | ||
# | ||
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT | ||
|
||
# enable 'SingleOwnNamespaceInstallSupport' feature gate | ||
kubectl patch deployment -n olmv1-system operator-controller-controller-manager --type='json' -p='[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--feature-gates=SingleOwnNamespaceInstallSupport=true"}]' | ||
|
||
# wait for operator-controller to become available | ||
kubectl rollout status -n olmv1-system deployment/operator-controller-controller-manager | ||
|
||
# create install namespace | ||
kubectl create ns argocd-system | ||
|
||
# create installer service account | ||
kubectl create serviceaccount -n argocd-system argocd-installer | ||
|
||
# give installer service account admin privileges (not for production environments) | ||
kubectl create clusterrolebinding argocd-installer-crb --clusterrole=cluster-admin --serviceaccount=argocd-system:argocd-installer | ||
|
||
# create watch namespace | ||
kubectl create namespace argocd | ||
|
||
# install cluster extension in single namespace install mode (watch namespace != install namespace) | ||
cat ${DEMO_RESOURCE_DIR}/single-namespace-demo.yaml | ||
|
||
# apply cluster extension | ||
kubectl apply -f ${DEMO_RESOURCE_DIR}/single-namespace-demo.yaml | ||
|
||
# wait for cluster extension installation to succeed | ||
kubectl wait --for=condition=Installed clusterextension/argocd-operator --timeout="60s" | ||
|
||
# check argocd-operator controller deployment pod template olm.targetNamespaces annotation | ||
kubectl get deployments -n argocd-system argocd-operator-controller-manager -o jsonpath="{.spec.template.metadata.annotations.olm\.targetNamespaces}" | ||
|
||
# check for argocd-operator rbac in watch namespace | ||
kubectl get roles,rolebindings -n argocd -o name | ||
|
||
# get controller service-account name | ||
kubectl get deployments -n argocd-system argocd-operator-controller-manager -o jsonpath="{.spec.template.spec.serviceAccount}" | ||
|
||
# check service account for role binding is the controller deployment service account | ||
rolebinding=$(kubectl get rolebindings -n argocd -o name | grep 'argocd-operator' | head -n 1) | ||
kubectl get -n argocd $rolebinding -o jsonpath='{.subjects}' | jq .[0] |
Uh oh!
There was an error while loading. Please reload this page.