Skip to content

Commit

Permalink
refactor: gitops
Browse files Browse the repository at this point in the history
  • Loading branch information
codekow committed Oct 4, 2024
1 parent 47e39a5 commit f694753
Show file tree
Hide file tree
Showing 18 changed files with 156 additions and 34 deletions.
17 changes: 17 additions & 0 deletions gitops/00-cluster-config/adhoc-ops/00-job/job.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# shellcheck disable=SC1091
. /scripts/ocp.sh

ocp_allow_router_on_control_plane(){
oc -n openshift-ingress-operator \
patch ingresscontroller default \
--type=merge --patch '{"spec":{"nodePlacement":{"tolerations":[{"key":"node-role.kubernetes.io/master","operator":"Exists","effect":"NoSchedule"}]}}}'
}

ocp_aws_cluster || exit 0
ocp_clean_install_pods
ocp_scale_machineset 1
ocp_control_nodes_not_schedulable
ocp_set_scheduler_profile HighNodeUtilization
ocp_allow_router_on_control_plane
32 changes: 32 additions & 0 deletions gitops/00-cluster-config/adhoc-ops/00-job/job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
apiVersion: batch/v1
kind: Job
metadata:
generateName: job-setup-cluster-
name: job-setup-cluster
# annotations:
# argocd.argoproj.io/hook: Sync
# argocd.argoproj.io/hook-delete-policy: HookSucceeded
spec:
template:
spec:
containers:
- name: job-setup-cluster
# image: image-registry.openshift-image-registry.svc:5000/openshift/tools:latest
image: registry.redhat.io/openshift4/ose-cli
command:
- /bin/bash
- -c
- /scripts/job.sh
volumeMounts:
- name: scripts
mountPath: /scripts
volumes:
- name: scripts
configMap:
name: job-setup-cluster
defaultMode: 0755
restartPolicy: Never
terminationGracePeriodSeconds: 30
serviceAccount: cluster-admin-minion
serviceAccountName: cluster-admin-minion
15 changes: 15 additions & 0 deletions gitops/00-cluster-config/adhoc-ops/00-job/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component

resources:
- job.yaml

generatorOptions:
disableNameSuffixHash: true

configMapGenerator:
- name: job-setup-cluster
files:
# - functions.sh
- job.sh
- https://raw.githubusercontent.com/redhat-na-ssa/demo-ai-gitops-catalog/v0.05/scripts/library/ocp.sh
23 changes: 23 additions & 0 deletions gitops/00-cluster-config/adhoc-ops/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# adhoc-ops

## Purpose

You ~~are lazy~~ want to avoid running imperative commands on the local command line to setup your cluster.

This component has been tested using AWS based OpenShift instances provisioned by [demo.redhat.com](https://demo.redhat.com).

NOTE: The creates a service account with `cluster-admin` - DO NOT DO THIS IN PRODUCTION! Setup specific roles for a task

## Usage

```yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- base

components:
- 00-job
- 01-job
```
11 changes: 11 additions & 0 deletions gitops/00-cluster-config/adhoc-ops/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: adhoc-ops

resources:
- namespace.yaml
- rbac.yaml

components:
- setup-job
8 changes: 8 additions & 0 deletions gitops/00-cluster-config/adhoc-ops/base/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Namespace
metadata:
name: adhoc-ops
annotations:
openshift.io/display-name: "Adhoc Ops"
openshift.io/description: |
I Make This Look Easy
23 changes: 23 additions & 0 deletions gitops/00-cluster-config/adhoc-ops/base/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: cluster-admin-minion
namespace: adhoc-ops
annotations:
NOT-FOR-PRODUCTION: EVER
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: cluster-admin-minion
annotations:
NOT-FOR-PRODUCTION: EVER
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: cluster-admin-minion
namespace: adhoc-ops
10 changes: 10 additions & 0 deletions gitops/00-cluster-config/adhoc-ops/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: adhoc-ops

resources:
- base

components:
- 00-job
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ kind: Kustomization

resources:
- https://github.com/redhat-na-ssa/demo-ai-gitops-catalog/clusters/default?ref=v0.05
- link-github.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: console.openshift.io/v1
kind: ConsoleLink
metadata:
name: github-ai-devspaces
name: github-flyingthings
spec:
href: 'https://github.com/redhat-na-ssa/flyingthings'
location: ApplicationMenu
Expand Down
2 changes: 1 addition & 1 deletion gitops/00-operators/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ resources:
- https://github.com/redhat-na-ssa/demo-ai-gitops-catalog/components/operators/devspaces/operator/overlays/stable?ref=v0.05
- https://github.com/redhat-na-ssa/demo-ai-gitops-catalog/components/operators/gpu-operator-certified/operator/overlays/stable?ref=v0.05
- https://github.com/redhat-na-ssa/demo-ai-gitops-catalog/components/operators/nfd/operator/overlays/stable?ref=v0.05
- https://github.com/redhat-na-ssa/demo-ai-gitops-catalog/components/operators/openshift-pipelines-operator-rh/operator/overlays/pipelines-1.11?ref=v0.05
- https://github.com/redhat-na-ssa/demo-ai-gitops-catalog/components/operators/openshift-pipelines-operator-rh/operator/overlays/pipelines-1.14?ref=v0.05
9 changes: 9 additions & 0 deletions gitops/02-ml-demo/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: ml-demo

resources:
- ../user-components
- namespace.yaml
- ns-rb-view.yaml
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions gitops/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
# - 00-operators
# - 01-operator-configs
- 02-components
- demo-devspaces-nvidia-gpu-autoscale
- 00-cluster-config
- 00-operators
- 01-operator-configs
- 02-ml-demo

patches:
- target:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: ml-demo

resources:
- ../../components/custom-image
- ../../components/label-studio
- ../../components/minio
- ../../components/yolo-api/base
- ../../components/pipelines
- link-github.yaml
- namespace.yaml
- ns-rb-view.yaml
22 changes: 0 additions & 22 deletions scripts/00-setup-components.sh

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ until_true(){
check_cluster_version(){
OCP_VERSION=$(oc version | sed -n '/Server Version: / s/Server Version: //p')
AVOID_VERSIONS=()
TESTED_VERSIONS=("4.12.12" "4.12.33")
TESTED_VERSIONS=("4.12.12" "4.12.33" "4.14.37")

echo "Current OCP version: ${OCP_VERSION}"
echo "Tested OCP version(s): ${TESTED_VERSIONS[*]}"
Expand Down

0 comments on commit f694753

Please sign in to comment.