-
Notifications
You must be signed in to change notification settings - Fork 18
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
ability to install Operator with an alternate namcespace than the default (porter-operator-system) #191
base: main
Are you sure you want to change the base?
ability to install Operator with an alternate namcespace than the default (porter-operator-system) #191
Changes from all commits
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 | ||||
---|---|---|---|---|---|---|
@@ -1,6 +1,23 @@ | ||||||
#!/usr/bin/env bash | ||||||
set -euo pipefail | ||||||
|
||||||
OPNAMESPACE="porter-operator-system" | ||||||
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. This works but I wanted you to know about a porter feature in case that affects how you'd like to implement this. The parameter operatorNamespace is always populated, it will have the default value if not specified by the user, and a corresponding environment variable, |
||||||
|
||||||
setCustomNamespaceForOperator() { | ||||||
if [ -z "$1" ]; then | ||||||
echo "No namespace specified, using default $OPNAMESPACE" | ||||||
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. Let's always be clear which namespace we are referring to in these messages, because we have both the "porter operator namespace" and also a namespace that is created and configured by the
Suggested change
|
||||||
else | ||||||
OPNAMESPACE=$1 | ||||||
echo "Using custom namespace $OPNAMESPACE" | ||||||
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.
Suggested change
|
||||||
fi | ||||||
|
||||||
# Replace the namespace in the operator.yaml | ||||||
echo "Setting namespace to $OPNAMESPACE" | ||||||
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.
Suggested change
|
||||||
cd manifests | ||||||
kustomize edit set namespace $OPNAMESPACE | ||||||
kustomize build -o operator.yaml | ||||||
} | ||||||
|
||||||
setControllerImage() { | ||||||
# Replace the manager image with the image packaged with the bundle | ||||||
echo "Setting manager image to $1" | ||||||
|
@@ -46,11 +63,15 @@ configureNamespace() { | |||||
} | ||||||
|
||||||
waitForDeployment() { | ||||||
if [ ! -z "$1" ]; then | ||||||
OPNAMESPACE=$1 | ||||||
fi | ||||||
|
||||||
set +e # allow this next command to fail | ||||||
kubectl rollout status deploy/porter-operator-controller-manager --namespace porter-operator-system --timeout 30s | ||||||
kubectl rollout status deploy/porter-operator-controller-manager --namespace $OPNAMESPACE --timeout 30s | ||||||
if [[ $? != 0 ]]; then | ||||||
echo "Deployment failed, retrieving logs to troubleshoot" | ||||||
kubectl logs deploy/porter-operator-controller-manager --namespace porter-operator-system -c manager | ||||||
kubectl logs deploy/porter-operator-controller-manager --namespace $OPNAMESPACE -c manager | ||||||
fi | ||||||
} | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -68,6 +68,13 @@ parameters: | |||||||||||||||
default: "13.6.2" | ||||||||||||||||
applyTo: | ||||||||||||||||
- install | ||||||||||||||||
- name: operatorNamespace | ||||||||||||||||
description: Namespace to install the operator into | ||||||||||||||||
type: string | ||||||||||||||||
default: "porter-operator-system" | ||||||||||||||||
applyTo: | ||||||||||||||||
- install | ||||||||||||||||
- upgrade | ||||||||||||||||
Comment on lines
+75
to
+77
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. The
Suggested change
|
||||||||||||||||
- name: mongodbVals | ||||||||||||||||
description: Helm values file to use when installing the mongodb chart | ||||||||||||||||
type: file | ||||||||||||||||
|
@@ -88,6 +95,12 @@ mixins: | |||||||||||||||
- kubernetes | ||||||||||||||||
|
||||||||||||||||
install: | ||||||||||||||||
- exec: | ||||||||||||||||
description: "Set custom namespace for operator if present" | ||||||||||||||||
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.
Suggested change
The parameter |
||||||||||||||||
command: ./helpers.sh | ||||||||||||||||
arguments: | ||||||||||||||||
- setCustomNamespaceForOperator | ||||||||||||||||
- ${bundle.parameters.operatorNamespace} | ||||||||||||||||
- exec: | ||||||||||||||||
description: "Set manager image reference" | ||||||||||||||||
command: ./helpers.sh | ||||||||||||||||
|
@@ -101,7 +114,7 @@ install: | |||||||||||||||
wait: true | ||||||||||||||||
- helm3: | ||||||||||||||||
description: "Install a mongo database for Porter" | ||||||||||||||||
namespace: porter-operator-system | ||||||||||||||||
namespace: ${bundle.parameters.operatorNamespace} | ||||||||||||||||
name: mongodb | ||||||||||||||||
chart: bitnami/mongodb | ||||||||||||||||
version: ${bundle.parameters.mongodbChartVersion} | ||||||||||||||||
|
@@ -115,8 +128,15 @@ install: | |||||||||||||||
command: ./helpers.sh | ||||||||||||||||
arguments: | ||||||||||||||||
- waitForDeployment | ||||||||||||||||
- ${bundle.parameters.operatorNamespace} | ||||||||||||||||
|
||||||||||||||||
upgrade: | ||||||||||||||||
- exec: | ||||||||||||||||
description: "Set custom namespace for operator if present" | ||||||||||||||||
command: ./helpers.sh | ||||||||||||||||
arguments: | ||||||||||||||||
- setCustomNamespaceForOperator | ||||||||||||||||
- ${bundle.parameters.operatorNamespace} | ||||||||||||||||
- exec: | ||||||||||||||||
description: "Set manager image reference" | ||||||||||||||||
command: ./helpers.sh | ||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -284,7 +284,7 @@ func TestIntegration() { | |
// are responding to the same events. | ||
// For now, it's up to the caller to use a fresh cluster with CRDs installed until we can fix it. | ||
|
||
kubectl("delete", "deployment", "porter-operator-controller-manager", "-n=porter-operator-system").RunV() | ||
kubectl("delete", "deployment", "porter-operator-controller-manager", "-n="+operatorNamespace).RunV() | ||
|
||
if os.Getenv("PORTER_AGENT_REPOSITORY") != "" && os.Getenv("PORTER_AGENT_VERSION") != "" { | ||
porterAgentImgRepository = os.Getenv("PORTER_AGENT_REPOSITORY") | ||
|
@@ -334,7 +334,7 @@ func Deploy() { | |
buildPorterCmd("credentials", "apply", "hack/creds.yaml", "-n=operator").Must().RunV() | ||
} | ||
bundleRef := Env.BundlePrefix + meta.Version | ||
installCmd := buildPorterCmd("install", "operator", "-r", bundleRef, "-c=kind", "--force", "-n=operator").Must() | ||
installCmd := buildPorterCmd("install", "operator", "-r", bundleRef, "-c=kind", "--force", "-n=operator", "--param", "operatorNamespace="+operatorNamespace).Must() | ||
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. Let's follow the pattern for allowing the developer to customize development parameters, like PORTER_AGENT_REPOSITORY, using local environment variables instead of requiring changes to the code. The function |
||
applyHackParameters(installCmd) | ||
installCmd.RunV() | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
configureNamespace
function is used by the configureNamespace custom action for the bundle, it sets up a namespace for use with the operator with required configuration such as a porter configuration file. By default we use the contents of installer/manifests/namespace/defaults/porter-config-spec.yaml. In that file, we reference the in-cluster mongodb service that is installed in the operator namespace and it's hard-coded to porter-operator-system.The configureNamespace helper function should also update that file when a custom porter configuration file was not specified to use the custom operator namespace.