-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11d35cd
commit cd74001
Showing
7 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,6 @@ kind: Kustomization | |
|
||
resources: | ||
- subscription.yaml | ||
|
||
components: | ||
- ../components/enable-console-plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# OpenShift GitOps Components | ||
|
||
The included components are intended to be common patching patterns used on top of the default OpenShift Gitops operator to configure additional features of the operator. Components are composable patches that can be added at the overlays layer on top of a base or overlay | ||
|
||
This repo currently contains the following components: | ||
|
||
* [enable-console-plugin](enable-console-plugin) | ||
* [openshift-gitops-operator](openshift-gitops-operator) | ||
|
||
## Usage | ||
|
||
Components can be added to a base by adding the `components` section to your overlay `kustomization.yaml` file: | ||
|
||
``` | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
resources: | ||
- ../../base | ||
components: | ||
- ../../components/enable-console-plugin | ||
``` |
17 changes: 17 additions & 0 deletions
17
openshift-gitops-operator/operator/components/enable-console-plugin/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# enable-console-plugin | ||
|
||
## Purpose | ||
This component is designed to enable the OpenShift GitOps Console Plugin. | ||
|
||
## Usage | ||
|
||
This component can be added to a base by adding the `components` section to your overlay `kustomization.yaml` file: | ||
|
||
``` | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
resources: | ||
- ../../base | ||
components: | ||
- ../../components/enable-console-plugin | ||
``` |
30 changes: 30 additions & 0 deletions
30
openshift-gitops-operator/operator/components/enable-console-plugin/console-plugin-job.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env bash | ||
|
||
enable_console_plugin(){ | ||
[ -z "${PLUGIN_NAME}" ] && return 1 | ||
|
||
echo "Attempting to enable ${PLUGIN_NAME} plugin" | ||
echo "" | ||
|
||
# Create the plugins section on the object if it doesn't exist | ||
if [ -z "$(oc get consoles.operator.openshift.io cluster -o=jsonpath='{.spec.plugins}')" ]; then | ||
echo "Creating plugins object" | ||
oc patch consoles.operator.openshift.io cluster --patch '{ "spec": { "plugins": [] } }' --type=merge | ||
fi | ||
|
||
INSTALLED_PLUGINS=$(oc get consoles.operator.openshift.io cluster -o=jsonpath='{.spec.plugins}') | ||
echo "Current plugins:" | ||
echo "${INSTALLED_PLUGINS}" | ||
|
||
if [[ "${INSTALLED_PLUGINS}" == *"${PLUGIN_NAME}"* ]]; then | ||
echo "${PLUGIN_NAME} is already enabled" | ||
else | ||
echo "Enabling plugin: ${PLUGIN_NAME}" | ||
oc patch consoles.operator.openshift.io cluster --type=json --patch '[{"op": "add", "path": "/spec/plugins/-", "value": "'"${PLUGIN_NAME}"'"}]' | ||
fi | ||
|
||
sleep 6 | ||
oc get consoles.operator.openshift.io cluster -o=jsonpath='{.spec.plugins}' | ||
} | ||
|
||
enable_console_plugin |
64 changes: 64 additions & 0 deletions
64
openshift-gitops-operator/operator/components/enable-console-plugin/console-plugin-job.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: job-gitops-console-plugin | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: job-gitops-console-plugin | ||
rules: | ||
- apiGroups: | ||
- operator.openshift.io | ||
resources: | ||
- consoles | ||
verbs: | ||
- get | ||
- list | ||
- patch | ||
- label | ||
--- | ||
kind: ClusterRoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: job-gitops-console-plugin | ||
subjects: | ||
- kind: ServiceAccount | ||
name: job-gitops-console-plugin | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: job-gitops-console-plugin | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: job-gitops-console-plugin | ||
annotations: | ||
argocd.argoproj.io/sync-wave: "10" | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: minion | ||
image: registry.redhat.io/openshift4/ose-cli | ||
env: | ||
- name: PLUGIN_NAME | ||
value: gitops-plugin | ||
command: | ||
- /bin/bash | ||
- -c | ||
- /scripts/console-plugin-job.sh | ||
volumeMounts: | ||
- name: scripts | ||
mountPath: /scripts | ||
volumes: | ||
- name: scripts | ||
configMap: | ||
name: job-gitops-console-plugin | ||
defaultMode: 0755 | ||
restartPolicy: Never | ||
serviceAccount: job-gitops-console-plugin | ||
serviceAccountName: job-gitops-console-plugin | ||
backoffLimit: 4 |
15 changes: 15 additions & 0 deletions
15
openshift-gitops-operator/operator/components/enable-console-plugin/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: kustomize.config.k8s.io/v1alpha1 | ||
kind: Component | ||
|
||
namespace: openshift-gitops | ||
|
||
resources: | ||
- console-plugin-job.yaml | ||
|
||
generatorOptions: | ||
disableNameSuffixHash: true | ||
|
||
configMapGenerator: | ||
- name: job-gitops-console-plugin | ||
files: | ||
- console-plugin-job.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters