Skip to content
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
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

#TODO add default features here
export FEATURES?=sctp
export FEATURES?=sctp performance

# The environment represents the kustomize patches to apply when deploying the features
export FEATURES_ENVIRONMENT?=e2e-gcp
Expand Down Expand Up @@ -33,9 +32,9 @@ deps-update:
go mod tidy && \
go mod vendor

functests:
functests: label-worker-rt feature-deploy
@echo "Running Functional Tests"
FEATURES=$(FEATURES) hack/run-functests.sh
FEATURES="$(FEATURES)" hack/run-functests.sh

gofmt:
@echo "Running gofmt"
Expand Down Expand Up @@ -64,4 +63,8 @@ kustomize:
fi

feature-deploy: kustomize
KUSTOMIZE=$(KUSTOMIZE) FEATURES_ENVIRONMENT=$(FEATURES_ENVIRONMENT) FEATURES=$(FEATURES) hack/feature-deploy.sh
KUSTOMIZE=$(KUSTOMIZE) FEATURES_ENVIRONMENT=$(FEATURES_ENVIRONMENT) FEATURES="$(FEATURES)" hack/feature-deploy.sh

label-worker-rt:
@echo "Adding worker-rt label to one worker node"
hack/label-worker-rt.sh
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,17 @@ This repo contains example kustomize configs used to installed openshift feature

# Contributing kustomize configs

All kustomize configs should be entirely declarative in nature. This means no bash plugin modules performing imparative tasks. Features should be installed simply by posting manifests to the cluster. After posting manifests, determining when the cluster has converged on those manifests successully should be observable.
All kustomize configs should be entirely declarative in nature. This means no bash plugin modules performing imparative tasks. Features should be installed simply by posting manifests to the cluster. After posting manifests, determining when the cluster has converged on those manifests successully should be observable.

# Usage

## Prerequisites

- You need a running OCP 4.4 cluster and a valid KUBECONFIG.
- You need at least one node with the `node-role.kubernetes.io/worker-rt=""` label.
Run `make label-worker-rt` for adding it on the first `worker` node of the cluster.

## Deployment

- run `FEATURES_ENVIRONMENT=demo make feature-deploy`.
This will try to apply all manifests in a loop until all deployments succeeded, or until it runs into a timeout.
11 changes: 11 additions & 0 deletions feature-configs/base/performance/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

# TODO handle namespace with var

resources:
- operator-namespace.yaml
- operator_operatorgroup.yaml
- operator_catalogsource.yaml
- operator_subscription.yaml
- performance_profile.yaml
7 changes: 7 additions & 0 deletions feature-configs/base/performance/operator-namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Namespace
metadata:
labels:
openshift.io/cluster-monitoring: "true"
name: openshift-performance-addon
spec: {}
13 changes: 13 additions & 0 deletions feature-configs/base/performance/operator_catalogsource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: performance-addon-operators-catalogsource
namespace: openshift-marketplace
spec:
displayName: Openshift Performance Addon Operators
icon:
base64data: ""
mediatype: ""
image: quay.io/openshift/performance-addon-operators-registry
publisher: Red Hat
sourceType: grpc
8 changes: 8 additions & 0 deletions feature-configs/base/performance/operator_operatorgroup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: openshift-performance-addon-operatorgroup
namespace: openshift-performance-addon
spec:
targetNamespaces:
- openshift-performance-addon
10 changes: 10 additions & 0 deletions feature-configs/base/performance/operator_subscription.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: performance-addon-operators-subscription
namespace: openshift-performance-addon
spec:
channel: alpha
name: performance-addon-operators
source: performance-addon-operators-catalogsource
sourceNamespace: openshift-marketplace
16 changes: 16 additions & 0 deletions feature-configs/base/performance/performance_profile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: performance.openshift.io/v1alpha1
kind: PerformanceProfile
metadata:
name: performance
spec:
cpu:
isolated: "1-3"
nonIsolated: "0"
reserved: "0-1"
hugepages:
defaultHugepagesSize: "1G"
pages:
- size: "1G"
count: 1
realTimeKernel:
enabled: true
9 changes: 9 additions & 0 deletions feature-configs/demo/performance/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../base/performance

patchesStrategicMerge:
- operator_catalogsource.patch.yaml
- performance_profile.patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: performance-addon-operators-catalogsource
namespace: openshift-marketplace
spec:
image: quay.io/slintes/performance-addon-operators-registry
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: performance.openshift.io/v1alpha1
kind: PerformanceProfile
metadata:
name: performance
spec:
nodeSelector:
node-role.kubernetes.io/worker-rt: ""
9 changes: 9 additions & 0 deletions feature-configs/e2e-gcp/performance/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../base/performance

patchesStrategicMerge:
- operator_catalogsource.patch.yaml
- performance_profile.patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: performance-addon-operators-catalogsource
namespace: openshift-marketplace
spec:
image: quay.io/slintes/performance-addon-operators-registry
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: performance.openshift.io/v1alpha1
kind: PerformanceProfile
metadata:
name: performance
spec:
nodeSelector:
node-role.kubernetes.io/worker-rt: ""
64 changes: 60 additions & 4 deletions hack/feature-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,67 @@

set -e

if [ "$FEATURES_ENVIRONMENT" == "" ]; then
echo "[ERROR]: No FEATURES_ENVIRONMENT provided"
exit 1
fi

if [ "$FEATURES" == "" ]; then
echo "[ERROR]: No FEATURES provided"
exit 1
fi

# expect oc to be in PATH by default
OC_TOOL="${OC_TOOL:-oc}"
export OC_TOOL="${OC_TOOL:-oc}"

# expect kustomize to be in PATH by default
KUSTOMIZE="${KUSTOMIZE:-kustomize}"

# Deploy features
success=0
iterations=0
sleep_time=10
max_iterations=30 # results in 5 minute timeout
until [[ $success -eq 1 ]] || [[ $iterations -eq $max_iterations ]]
do

feature_failed=0

for feature in $FEATURES; do

feature_dir=feature-configs/${FEATURES_ENVIRONMENT}/${feature}/
if [[ ! -d $feature_dir ]]; then
echo "[WARN] Feature '$feature' is not configured for environment '$FEATURES_ENVIRONMENT', skipping it"
continue
fi

echo "[INFO] Deploying feature '$feature' for environment '$FEATURES_ENVIRONMENT'"
set +e
if ! ${KUSTOMIZE} build $feature_dir | ${OC_TOOL} apply -f -
then
echo "[WARN] Deployment of feature '$feature' failed."
feature_failed=1
fi
set -e

done

@yuvalk yuvalk Jan 14, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this logic can be better:

  1. afaik apply will return 0 regardless of other errors that might occur
  2. even if such errors occur, there's no need to re-apply, just wait for them to settle.
  3. which this loop doesnt do (something like kubectl rollout status, which isn't available in oc[??] not sure whats the alternative). ie we would probably be out of that loop before features declarations are really "done"

other then that, we can use a single oc apply -k, if we create a folder referencing all the wanted features.
which IMHO would be 'cleaner' than running multiple kustomize commands. we can even have an overlay dir with some supported/most relevant variations (all, networking, performance, etc)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for review!

  1. no, this works: as long as the CR can't be posted because the CRD isn't there yet, it returns an error
  2. we don't want custom wait logic, that's why we iterate until all succeeds. Custom wait would be "check if CRD exists already"
  3. yes, we might want to have a sanity check that everything works as expected. I'd like to leave that out of scope of this PR, in order to get it merged asap, so that others can add more features on top of this
  4. about oc -k, see Added kustomization for performance #4 (comment)


if [[ $feature_failed -eq 1 ]]; then
iterations=$((iterations + 1))
iterations_left=$((max_iterations - iterations))
echo "[WARN] At least one deployment failed, retrying in $sleep_time sec, $iterations_left retries left"
sleep $sleep_time
continue

fi

# All features deployed successfully
success=1

for f in $FEATURES; do
echo "TODO add logic to implement feature '$f' for environment '$FEATURES_ENVIRONMENT'"
done

echo "ERROR: FEATURE DEPLOY SCRIPT $0 NEEDS IMPLEMENTATION"
if [[ $success -eq 1 ]]; then
echo "[INFO] Deployment successful"
else
echo "[ERROR] Deployment failed"
fi
11 changes: 11 additions & 0 deletions hack/label-worker-rt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e

# expect oc to be in PATH by default
export OC_TOOL="${OC_TOOL:-oc}"

# Label 1 worker node
echo "[INFO]: Labeling 1 worker node with worker-rt"
node=$(${OC_TOOL} get nodes --selector='node-role.kubernetes.io/worker' -o name | head -1)
${OC_TOOL} label $node node-role.kubernetes.io/worker-rt=""