Skip to content

Commit

Permalink
Merge pull request #20 from pdettori/pin-versions
Browse files Browse the repository at this point in the history
🐛  pin version and minor fixes
  • Loading branch information
pdettori authored Jul 24, 2024
2 parents 8b49f2e + 691f22d commit 200a203
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 36 deletions.
10 changes: 10 additions & 0 deletions scripts/common/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,13 @@

# wec used in the setup
clusters=(cluster1 cluster2);
core=kind-kubeflex

# charts versions
CLUSTER_METRICS_CHART_VERSION=0.0.1-alpha.6
MC_SCHEDULING_CHART_VERSION=0.0.1-alpha.6
SHADOW_PODS_VERSION=0.0.1-alpha.6
SUSPEND_WEBHOOK_VERSION=0.0.1-alpha.6

# Kubeflow Pipeline Version
PIPELINE_VERSION=2.2.0
28 changes: 14 additions & 14 deletions scripts/common/install-mcs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ trap cleanup EXIT

: install cluster-metrics controller on all clusters

cd ${SCRIPT_DIR}/../../clustermetrics
make ko-local-build

contexts=("${clusters[@]}")
contexts+=("kind-kubeflex")
contexts+=("${core}")
for context in "${contexts[@]}"; do
clusterName=${context}
cluster=${context}
if [[ ${context} == "kind-kubeflex" ]]; then
if [[ ${context} == ${core} ]]; then
clusterName="local"
cluster="kubeflex"
fi
CONTEXT=${context} CLUSTER=${cluster} HELM_OPTS="--set clusterName=${clusterName}" make install-local-chart
kubectl --context ${context} apply -f ${SCRIPT_DIR}/templates/cluster-metrics-rbac.yaml
else
kubectl --context ${context} apply -f ${SCRIPT_DIR}/templates/cluster-metrics-rbac.yaml
fi
helm --kube-context ${context} upgrade --install cluster-metrics \
oci://ghcr.io/kubestellar/galaxy/cluster-metrics-chart \
--version ${CLUSTER_METRICS_CHART_VERSION} \
--create-namespace --namespace clustermetrics-system \
--set clusterName=${clusterName}
done

: deploy cluster-metrics objects for each cluster
Expand All @@ -63,7 +63,7 @@ done

: install mc-scheduler on core cluster

cd ${SCRIPT_DIR}/../../mc-scheduling
kubectl config use-context kind-kubeflex
make ko-local-build
CLUSTER=kubeflex make install-local-chart
helm --kube-context ${core} upgrade --install mc-scheduling \
oci://ghcr.io/kubestellar/galaxy/mc-scheduling-chart \
--version ${MC_SCHEDULING_CHART_VERSION} \
--create-namespace --namespace mc-scheduling-system
64 changes: 63 additions & 1 deletion scripts/common/setup-shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,66 @@ while :; do
done
}

export -f wait-for-deployment
export -f wait-for-deployment

wait-for-apiresource() {
local context="$1"
local api_group="$2"
local resource_name="$3"
local interval_seconds=3

echo "Polling for Kubernetes resource '$resource_name' in API group '$api_group' every $interval_seconds seconds."

while true; do
# Get the list of all resources within the specified API group and check if the specified resource name is present
if kubectl --context ${core} api-resources --api-group="$api_group" | awk '{print $1}' | tail -n +2 | grep -q "^$resource_name$"; then
echo "Kubernetes resource '$resource_name' in API group '$api_group' has been found."
return 0
else
echo "Kubernetes resource '$resource_name' in API group '$api_group' not found yet. Retrying in $interval_seconds seconds..."
sleep "$interval_seconds"
fi
done
}

export -f wait-for-apiresource

# waits until all the deployments for a given context and namespace are ready
wait-for-all-deployments-in-namespace() {
context=$1
namespace=$2

local allReady=true
deployments=$(kubectl --context ${context} get deployments -n ${namespace} -o jsonpath='{.items[*].metadata.name}')
for deployment in $deployments; do
readyReplicas=$(kubectl --context ${context} get deployment $deployment -n ${namespace} -o jsonpath='{.status.readyReplicas}')
if [[ "$readyReplicas" -lt 1 ]]; then
allReady=false
break
fi
done
echo $allReady
}

export -f wait-for-all-deployments-in-namespace

# copies a secret from a source namespace namespace to a target namespace
copy-secret() {
# Check for correct number of arguments
if [ "$#" -ne 4 ]; then
echo "Usage: $0 <context> <source-namespace> <secret-name> <target-namespace>"
exit 1
fi

context=$1
SOURCE_NAMESPACE=$2
SECRET_NAME=$3
TARGET_NAMESPACE=$4

kubectl get secret $SECRET_NAME --namespace $SOURCE_NAMESPACE -o yaml | \
sed -e 's/namespace: .*//g' \
-e '/^ ownerReferences:/,/^ creationTimestamp:/d' | \
kubectl apply --namespace=$TARGET_NAMESPACE -f -
}

export -f copy-secret
46 changes: 25 additions & 21 deletions scripts/kfp/install-kfp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
source "${SCRIPT_DIR}/../common/setup-shell.sh"
source "${SCRIPT_DIR}/../common/config.sh"

export PIPELINE_VERSION=2.2.0

HOSTING_CLUSTER_NODE=kubeflex-control-plane
WORK_DIR=$(mktemp -d -p /tmp)
echo "using ${WORK_DIR} to clone repos"
Expand Down Expand Up @@ -154,44 +152,50 @@ rm ${SCRIPT_DIR}/kustomize/base/patch-pipeline-install-config.yaml

: install mutating admission webhook for workflows on kind-kubeflex

cd ${SCRIPT_DIR}/../../suspend-webhook
kubectl config use-context kind-kubeflex
make webhook-local-build && make install-webhook-local-chart
helm --kube-context ${core} upgrade --install suspend-webhook \
oci://ghcr.io/kubestellar/galaxy/suspend-webhook-chart \
--version ${SUSPEND_WEBHOOK_VERSION} \
--create-namespace --namespace ksi-system \
--set image.repository=ghcr.io/kubestellar/galaxy/suspend-webhook \
--set image.tag=${SUSPEND_WEBHOOK_VERSION}

: wait for admission webhook to be up

wait-for-cmd '(($(wrap-cmd kubectl --context kind-kubeflex get deployments -n ksi-system -o jsonpath='{.status.readyReplicas}' suspend-webhook 2>/dev/null || echo 0) >= 1))'
wait-for-deployment ${core} ksi-system suspend-webhook-suspend-webhook-chart

: install shadow pods controller

cd ${SCRIPT_DIR}/../../shadow-pods
kubectl config use-context kind-kubeflex
make loki-logger-local-build && make shadow-local-build && make install-shadow-local-chart
helm --kube-context ${core} upgrade --install shadow-pods \
oci://ghcr.io/kubestellar/galaxy/shadow-pods-chart \
--version ${SHADOW_PODS_VERSION} \
--create-namespace --namespace ksi-system \
--set image.repository=ghcr.io/kubestellar/galaxy/shadow-pods \
--set image.tag=${SHADOW_PODS_VERSION} \
--set lokiLoggerImage.repository=ghcr.io/kubestellar/galaxy/loki-logger \
--set lokiLoggerImage.tag=${SHADOW_PODS_VERSION} \
--set lokiInstallType=dev

: iwait for shadow pods controller to be up and running

wait-for-deployment ${core} ksi-system shadow-pods-shadow-pods-chart

: create binding policies for argo workflows

for cluster in "${clusters[@]}"; do
kubectl --context kind-kubeflex apply -f ${SCRIPT_DIR}/templates/wf-binding-policy-${cluster}.yaml
kubectl --context ${core} apply -f ${SCRIPT_DIR}/templates/wf-binding-policy-${cluster}.yaml
done

: create custom transform for argo workflows

kubectl --context kind-kubeflex apply -f ${SCRIPT_DIR}/templates/workflow-ct.yaml
kubectl --context ${core} apply -f ${SCRIPT_DIR}/templates/workflow-ct.yaml

: wait until all KFP deployments for kubeflow are up in all clusters, this may take tens of minutes

set +x
contexts=("${clusters[@]}")
contexts+=("kind-kubeflex")
contexts+=("${core}")
for context in "${contexts[@]}"; do
while true; do
if [[ $(check_pods_ready ${context}) == true ]]; then
echo "All deployments for ${context} are in ready state."
break
else
echo "Not all deployments in ${context} are ready yet. Waiting..."
sleep 5
fi
done
echo "checking all pods ready in context ${context} kubeflow. Please wait...."
wait-for-all-deployments-in-namespace ${context} kubeflow
done
set -x
7 changes: 7 additions & 0 deletions shadow-pods/internal/controller/workflow_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,13 @@ func generatePodTemplate(podInfo PodInfo, image, lokiInstallType, CertsSecretNam
Type: corev1.SeccompProfileTypeRuntimeDefault,
},
}
} else {
extraEnv := []corev1.EnvVar{{
Name: "LOKI_INSTALL_TYPE",
Value: LokiInstallTypeDev,
},
}
podTemplate.Spec.Containers[0].Env = append(podTemplate.Spec.Containers[0].Env, extraEnv...)
}
return podTemplate
}
Expand Down

0 comments on commit 200a203

Please sign in to comment.