Skip to content

Commit

Permalink
Make Scylla Operator resources configurable in CI scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
rzetelskik committed Jan 13, 2025
1 parent 7ed4ab4 commit 73e4bc3
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 12 deletions.
5 changes: 2 additions & 3 deletions hack/.ci/run-e2e-gke-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ fi

source "$( dirname "${BASH_SOURCE[0]}" )/../lib/kube.sh"
source "$( dirname "${BASH_SOURCE[0]}" )/lib/e2e.sh"
source "$( dirname "${BASH_SOURCE[0]}" )/run-e2e-shared.env.sh"

parent_dir="$( dirname "${BASH_SOURCE[0]}" )"

trap gather-artifacts-on-exit EXIT
Expand All @@ -23,9 +25,6 @@ export SO_NODECONFIG_PATH
SO_SCYLLACLUSTER_STORAGECLASS_NAME="${SO_SCYLLACLUSTER_STORAGECLASS_NAME=scylladb-local-xfs}"
export SO_SCYLLACLUSTER_STORAGECLASS_NAME

SCYLLA_OPERATOR_FEATURE_GATES="${SCYLLA_OPERATOR_FEATURE_GATES:-AllAlpha=true,AllBeta=true}"
export SCYLLA_OPERATOR_FEATURE_GATES

for i in "${!KUBECONFIGS[@]}"; do
KUBECONFIG="${KUBECONFIGS[$i]}" ARTIFACTS_DEPLOY_DIR="${ARTIFACTS}/deploy/${i}" timeout --foreground -v 10m "${parent_dir}/../ci-deploy-release.sh" "${SO_IMAGE}" &
ci_deploy_bg_pids["${i}"]=$!
Expand Down
4 changes: 1 addition & 3 deletions hack/.ci/run-e2e-gke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ fi

source "$( dirname "${BASH_SOURCE[0]}" )/../lib/kube.sh"
source "$( dirname "${BASH_SOURCE[0]}" )/lib/e2e.sh"
source "$( dirname "${BASH_SOURCE[0]}" )/run-e2e-shared.env.sh"
parent_dir="$( dirname "${BASH_SOURCE[0]}" )"

trap gather-artifacts-on-exit EXIT
Expand All @@ -30,9 +31,6 @@ if [[ "${SO_DISABLE_NODECONFIG:-false}" == "true" ]]; then
SO_CSI_DRIVER_PATH=""
fi

SCYLLA_OPERATOR_FEATURE_GATES="${SCYLLA_OPERATOR_FEATURE_GATES:-AllAlpha=true,AllBeta=true}"
export SCYLLA_OPERATOR_FEATURE_GATES

for i in "${!KUBECONFIGS[@]}"; do
KUBECONFIG="${KUBECONFIGS[$i]}" DEPLOY_DIR="${ARTIFACTS}/deploy/${i}" timeout --foreground -v 10m "${parent_dir}/../ci-deploy.sh" "${SO_IMAGE}" &
ci_deploy_bg_pids["${i}"]=$!
Expand Down
4 changes: 1 addition & 3 deletions hack/.ci/run-e2e-openshift-aws-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fi

source "$( dirname "${BASH_SOURCE[0]}" )/../lib/kube.sh"
source "$( dirname "${BASH_SOURCE[0]}" )/lib/e2e.sh"
source "$( dirname "${BASH_SOURCE[0]}" )/run-e2e-shared.env.sh"
parent_dir="$( dirname "${BASH_SOURCE[0]}" )"

trap gather-artifacts-on-exit EXIT
Expand All @@ -28,9 +29,6 @@ export SO_NODECONFIG_PATH
SO_SCYLLACLUSTER_STORAGECLASS_NAME="${SO_SCYLLACLUSTER_STORAGECLASS_NAME=scylladb-local-xfs}"
export SO_SCYLLACLUSTER_STORAGECLASS_NAME

SCYLLA_OPERATOR_FEATURE_GATES="${SCYLLA_OPERATOR_FEATURE_GATES:-AllAlpha=true,AllBeta=true}"
export SCYLLA_OPERATOR_FEATURE_GATES

for i in "${!KUBECONFIGS[@]}"; do
KUBECONFIG="${KUBECONFIGS[$i]}" DEPLOY_DIR="${ARTIFACTS}/deploy/${i}" timeout --foreground -v 10m "${parent_dir}/../ci-deploy-release.sh" "${SO_IMAGE}" &
ci_deploy_bg_pids["${i}"]=$!
Expand Down
4 changes: 1 addition & 3 deletions hack/.ci/run-e2e-openshift-aws.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fi

source "$( dirname "${BASH_SOURCE[0]}" )/../lib/kube.sh"
source "$( dirname "${BASH_SOURCE[0]}" )/lib/e2e.sh"
source "$( dirname "${BASH_SOURCE[0]}" )/run-e2e-shared.env.sh"
parent_dir="$( dirname "${BASH_SOURCE[0]}" )"

trap gather-artifacts-on-exit EXIT
Expand All @@ -29,9 +30,6 @@ export SO_CSI_DRIVER_PATH
SO_SCYLLACLUSTER_STORAGECLASS_NAME="${SO_SCYLLACLUSTER_STORAGECLASS_NAME=scylladb-local-xfs}"
export SO_SCYLLACLUSTER_STORAGECLASS_NAME

SCYLLA_OPERATOR_FEATURE_GATES="${SCYLLA_OPERATOR_FEATURE_GATES:-AllAlpha=true,AllBeta=true}"
export SCYLLA_OPERATOR_FEATURE_GATES

for i in "${!KUBECONFIGS[@]}"; do
KUBECONFIG="${KUBECONFIGS[$i]}" DEPLOY_DIR="${ARTIFACTS}/deploy/${i}" timeout --foreground -v 10m "${parent_dir}/../ci-deploy.sh" "${SO_IMAGE}" &
ci_deploy_bg_pids["${i}"]=$!
Expand Down
21 changes: 21 additions & 0 deletions hack/.ci/run-e2e-shared.env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
#
# Copyright (C) 2025 ScyllaDB
#

set -euExo pipefail
shopt -s inherit_errexit

SO_SCYLLA_OPERATOR_REPLICAS="${SO_SCYLLA_OPERATOR_REPLICAS:-1}"
export SO_SCYLLA_OPERATOR_REPLICAS
SO_SCYLLA_OPERATOR_RESOURCE_REQUESTS_CPU="${SO_SCYLLA_OPERATOR_RESOURCE_REQUEST_CPU:-4}"
export SO_SCYLLA_OPERATOR_RESOURCE_REQUESTS_CPU
SO_SCYLLA_OPERATOR_RESOURCE_REQUESTS_MEMORY="${SO_SCYLLA_OPERATOR_RESOURCE_REQUESTS_MEMORY:-2Gi}"
export SO_SCYLLA_OPERATOR_RESOURCE_REQUESTS_MEMORY
SO_SCYLLA_OPERATOR_RESOURCE_LIMITS_CPU="${SO_SCYLLA_OPERATOR_RESOURCE_REQUEST_CPU:-4}"
export SO_SCYLLA_OPERATOR_RESOURCE_LIMITS_CPU
SO_SCYLLA_OPERATOR_RESOURCE_LIMITS_MEMORY="${SO_SCYLLA_OPERATOR_RESOURCE_LIMITS_MEMORY:-2Gi}"
export SO_SCYLLA_OPERATOR_RESOURCE_LIMITS_MEMORY

SCYLLA_OPERATOR_FEATURE_GATES="${SCYLLA_OPERATOR_FEATURE_GATES:-AllAlpha=true,AllBeta=true}"
export SCYLLA_OPERATOR_FEATURE_GATES
100 changes: 100 additions & 0 deletions hack/ci-deploy-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,106 @@ patches:
name: scylla-operator
EOF

if [[ -n "${SO_SCYLLA_OPERATOR_REPLICAS:-}" ]]; then
# SO_SCYLLA_OPERATOR_REPLICAS is set and nonempty.
cat << EOF | \
yq eval-all --inplace 'select(fileIndex == 0) as $f | select(fileIndex == 1) as $p | with( $f.patches; . += $p | ... style="") | $f' "${ARTIFACTS_DEPLOY_DIR}/operator/kustomization.yaml" -
patch: |-
- op: replace
path: /spec/replicas
value: ${SO_SCYLLA_OPERATOR_REPLICAS}
target:
group: apps
version: v1
kind: Deployment
name: scylla-operator
EOF
fi

if [[ -n "${SO_SCYLLA_OPERATOR_RESOURCE_REQUESTS_CPU:-}" ]]; then
# SO_SCYLLA_OPERATOR_RESOURCE_REQUESTS_CPU is set and nonempty.
cat << EOF | \
yq eval-all --inplace 'select(fileIndex == 0) as $f | select(fileIndex == 1) as $p | with( $f.patches; . += $p | ... style="") | $f' "${ARTIFACTS_DEPLOY_DIR}/operator/kustomization.yaml" -
- patch: |-
apiVersion: apps/v1
kind: Deployment
metadata:
name: scylla-operator
namespace: scylla-operator
spec:
template:
spec:
containers:
- name: scylla-operator
resources:
requests:
cpu: "${SO_SCYLLA_OPERATOR_RESOURCE_REQUESTS_CPU}"
EOF
fi

if [[ -n "${SO_SCYLLA_OPERATOR_RESOURCE_REQUESTS_MEMORY:-}" ]]; then
# SO_SCYLLA_OPERATOR_RESOURCE_REQUESTS_MEMORY is set and nonempty.
cat << EOF | \
yq eval-all --inplace 'select(fileIndex == 0) as $f | select(fileIndex == 1) as $p | with( $f.patches; . += $p | ... style="") | $f' "${ARTIFACTS_DEPLOY_DIR}/operator/kustomization.yaml" -
- patch: |-
apiVersion: apps/v1
kind: Deployment
metadata:
name: scylla-operator
namespace: scylla-operator
spec:
template:
spec:
containers:
- name: scylla-operator
resources:
requests:
memory: "${SO_SCYLLA_OPERATOR_RESOURCE_REQUESTS_MEMORY}"
EOF
fi

if [[ -n "${SO_SCYLLA_OPERATOR_RESOURCE_LIMITS_CPU:-}" ]]; then
# SO_SCYLLA_OPERATOR_RESOURCE_LIMITS_CPU is set and nonempty.
cat << EOF | \
yq eval-all --inplace 'select(fileIndex == 0) as $f | select(fileIndex == 1) as $p | with( $f.patches; . += $p | ... style="") | $f' "${ARTIFACTS_DEPLOY_DIR}/operator/kustomization.yaml" -
- patch: |-
apiVersion: apps/v1
kind: Deployment
metadata:
name: scylla-operator
namespace: scylla-operator
spec:
template:
spec:
containers:
- name: scylla-operator
resources:
limits:
cpu: "${SO_SCYLLA_OPERATOR_RESOURCE_LIMITS_CPU}"
EOF
fi

if [[ -n "${SO_SCYLLA_OPERATOR_RESOURCE_LIMITS_MEMORY:-}" ]]; then
# SO_SCYLLA_OPERATOR_RESOURCE_LIMITS_MEMORY is set and nonempty.
cat << EOF | \
yq eval-all --inplace 'select(fileIndex == 0) as $f | select(fileIndex == 1) as $p | with( $f.patches; . += $p | ... style="") | $f' "${ARTIFACTS_DEPLOY_DIR}/operator/kustomization.yaml" -
- patch: |-
apiVersion: apps/v1
kind: Deployment
metadata:
name: scylla-operator
namespace: scylla-operator
spec:
template:
spec:
containers:
- name: scylla-operator
resources:
limits:
memory: "${SO_SCYLLA_OPERATOR_RESOURCE_LIMITS_MEMORY}"
EOF
fi

kubectl kustomize "${ARTIFACTS_DEPLOY_DIR}/operator" | kubectl_create -n=scylla-operator -f=-

# Manager needs scylla CRD registered and the webhook running
Expand Down
20 changes: 20 additions & 0 deletions hack/ci-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@ export SO_SCYLLA_OPERATOR_LOGLEVEL
yq e --inplace '.spec.template.spec.containers[0].args += "--loglevel=" + env(SO_SCYLLA_OPERATOR_LOGLEVEL)' "${DEPLOY_DIR}/operator/50_operator.deployment.yaml"
yq e --inplace '.spec.template.spec.containers[0].args += "--loglevel=" + env(SO_SCYLLA_OPERATOR_LOGLEVEL)' "${DEPLOY_DIR}/manager/50_controller_deployment.yaml"

if [[ -n "${SO_SCYLLA_OPERATOR_REPLICAS:-}" ]]; then
yq e --inplace '.spec.replicas = env(SO_SCYLLA_OPERATOR_REPLICAS)' "${DEPLOY_DIR}/operator/50_operator.deployment.yaml"
fi

if [[ -n "${SO_SCYLLA_OPERATOR_RESOURCE_REQUESTS_CPU:-}" ]]; then
yq e --inplace '.spec.template.spec.containers[0].resources.requests.cpu = env(SO_SCYLLA_OPERATOR_RESOURCE_REQUESTS_CPU)' "${DEPLOY_DIR}/operator/50_operator.deployment.yaml"
fi

if [[ -n "${SO_SCYLLA_OPERATOR_RESOURCE_REQUESTS_MEMORY:-}" ]]; then
yq e --inplace '.spec.template.spec.containers[0].resources.requests.memory = env(SO_SCYLLA_OPERATOR_RESOURCE_REQUESTS_MEMORY)' "${DEPLOY_DIR}/operator/50_operator.deployment.yaml"
fi

if [[ -n "${SO_SCYLLA_OPERATOR_RESOURCE_LIMITS_CPU:-}" ]]; then
yq e --inplace '.spec.template.spec.containers[0].resources.limits.cpu = env(SO_SCYLLA_OPERATOR_RESOURCE_LIMITS_CPU)' "${DEPLOY_DIR}/operator/50_operator.deployment.yaml"
fi

if [[ -n "${SO_SCYLLA_OPERATOR_RESOURCE_LIMITS_MEMORY:-}" ]]; then
yq e --inplace '.spec.template.spec.containers[0].resources.limits.memory = env(SO_SCYLLA_OPERATOR_RESOURCE_LIMITS_MEMORY)' "${DEPLOY_DIR}/operator/50_operator.deployment.yaml"
fi

yq e --inplace '.spec.template.spec.containers[0].args += ["--qps=200", "--burst=400"]' "${DEPLOY_DIR}/operator/50_operator.deployment.yaml"
yq e --inplace '.spec.template.spec.containers[0].args += ["--crypto-key-buffer-size-min=3", "--crypto-key-buffer-size-max=6", "--crypto-key-buffer-delay=2s"]' "${DEPLOY_DIR}/operator/50_operator.deployment.yaml"

Expand Down

0 comments on commit 73e4bc3

Please sign in to comment.