Skip to content
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

Add console plugin job for OpenShift Pipelines #296

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions openshift-pipelines-operator/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ namespace: openshift-operators

resources:
- subscription.yaml

components:
- ../components/enable-console-plugin
22 changes: 22 additions & 0 deletions openshift-pipelines-operator/components/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# OpenShift Pipelines Components

The included components are intended to be common patching patterns used on top of the default OpenShift Pipelines 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)

## 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
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# enable-console-plugin

## Purpose
This component is designed to enable the OpenShift Pipelines 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
```
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: job-tekton-console-plugin
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: job-tekton-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-tekton-console-plugin
subjects:
- kind: ServiceAccount
name: job-tekton-console-plugin
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: job-tekton-console-plugin
---
apiVersion: batch/v1
kind: Job
metadata:
name: job-tekton-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: pipelines-console-plugin
command:
- /bin/bash
- -c
- /scripts/console-plugin-job.sh
volumeMounts:
- name: scripts
mountPath: /scripts
volumes:
- name: scripts
configMap:
name: job-tekton-console-plugin
defaultMode: 0755
restartPolicy: Never
serviceAccount: job-tekton-console-plugin
serviceAccountName: job-tekton-console-plugin
backoffLimit: 4
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: console.openshift.io/v1
kind: ConsolePlugin
metadata:
name: pipelines-console-plugin
labels:
app.kubernetes.io/part-of: tekton-config
spec:
backend:
service:
basePath: /
name: pipelines-console-plugin
namespace: openshift-pipelines
port: 8443
type: Service
displayName: Pipelines Console Plugin
i18n:
loadType: Preload
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component

resources:
- console-plugin-job.yaml
- console-plugin.yaml

generatorOptions:
disableNameSuffixHash: true

configMapGenerator:
- name: job-tekton-console-plugin
files:
- console-plugin-job.sh
Loading