Skip to content

Commit

Permalink
Revert "Apply gitpod resources if there's diff (gitpod-io#16517)" (gi…
Browse files Browse the repository at this point in the history
…tpod-io#16642)

This reverts commit c487681.
  • Loading branch information
iQQBot authored Mar 3, 2023
1 parent b1ed3bf commit 695e528
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 36 deletions.
13 changes: 0 additions & 13 deletions dev/preview/workflow/lib/k8s-util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,3 @@ function readWerftSecret {
get secret "${name}" -o jsonpath="{.data.${key}}" \
| base64 -d
}

function diff-apply {
local context=$1
shift
local yaml=$1
yaml=$(realpath "${yaml}")

if kubectl --context "${context}" diff -f "${yaml}" > /dev/null; then
echo "Skipping ${yaml}, as it produced no diff"
else
kubectl --context "${context}" apply -f "${yaml}"
fi
}
51 changes: 29 additions & 22 deletions dev/preview/workflow/preview/deploy-gitpod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,35 @@ EOF
}

function installRookCeph {
diff-apply "${PREVIEW_K3S_KUBE_CONTEXT}" "$ROOT/.werft/vm/manifests/rook-ceph/crds.yaml"
kubectl \
--kubeconfig "${PREVIEW_K3S_KUBE_PATH}" \
--context "${PREVIEW_K3S_KUBE_CONTEXT}" \
apply -f "$ROOT/.werft/vm/manifests/rook-ceph/crds.yaml" --server-side --force-conflicts

kubectl \
--kubeconfig "${PREVIEW_K3S_KUBE_PATH}" \
--context "${PREVIEW_K3S_KUBE_CONTEXT}" \
wait --for condition=established --timeout=120s crd/cephclusters.ceph.rook.io

for file in common operator cluster-test storageclass-test snapshotclass;do
diff-apply "${PREVIEW_K3S_KUBE_CONTEXT}" "$ROOT/.werft/vm/manifests/rook-ceph/$file.yaml"
done
kubectl \
--kubeconfig "${PREVIEW_K3S_KUBE_PATH}" \
--context "${PREVIEW_K3S_KUBE_CONTEXT}" \
apply -f "$ROOT/.werft/vm/manifests/rook-ceph/common.yaml" -f "$ROOT/.werft/vm/manifests/rook-ceph/operator.yaml"

kubectl \
--kubeconfig "${PREVIEW_K3S_KUBE_PATH}" \
--context "${PREVIEW_K3S_KUBE_CONTEXT}" \
apply -f "$ROOT/.werft/vm/manifests/rook-ceph/cluster-test.yaml"

kubectl \
--kubeconfig "${PREVIEW_K3S_KUBE_PATH}" \
--context "${PREVIEW_K3S_KUBE_CONTEXT}" \
apply -f "$ROOT/.werft/vm/manifests/rook-ceph/storageclass-test.yaml"

kubectl \
--kubeconfig "${PREVIEW_K3S_KUBE_PATH}" \
--context "${PREVIEW_K3S_KUBE_CONTEXT}" \
apply -f "$ROOT/.werft/vm/manifests/rook-ceph/snapshotclass.yaml"
}

# Install Fluent-Bit sending logs to GCP
Expand Down Expand Up @@ -357,7 +376,7 @@ then
yq d -i admin-login-secret.yaml metadata.creationTimestamp
yq d -i admin-login-secret.yaml metadata.uid
yq d -i admin-login-secret.yaml metadata.resourceVersion
diff-apply "${PREVIEW_K3S_KUBE_CONTEXT}" admin-login-secret.yaml
kubectl --kubeconfig "${PREVIEW_K3S_KUBE_PATH}" --context "${PREVIEW_K3S_KUBE_CONTEXT}" apply -f admin-login-secret.yaml
rm -f admin-login-secret.yaml

yq w -i "${INSTALLER_CONFIG_PATH}" adminLoginSecret.kind "secret"
Expand All @@ -372,7 +391,7 @@ yq w -i stripe-api-keys.secret.yaml metadata.namespace "default"
yq d -i stripe-api-keys.secret.yaml metadata.creationTimestamp
yq d -i stripe-api-keys.secret.yaml metadata.uid
yq d -i stripe-api-keys.secret.yaml metadata.resourceVersion
diff-apply "${PREVIEW_K3S_KUBE_CONTEXT}" stripe-api-keys.secret.yaml
kubectl --kubeconfig "${PREVIEW_K3S_KUBE_PATH}" --context "${PREVIEW_K3S_KUBE_CONTEXT}" apply -f stripe-api-keys.secret.yaml
rm -f stripe-api-keys.secret.yaml

#
Expand All @@ -382,9 +401,8 @@ kubectl --kubeconfig "${DEV_KUBE_PATH}" --context "${DEV_KUBE_CONTEXT}" --namesp
| yq w - metadata.namespace ${PREVIEW_NAMESPACE} \
| yq d - metadata.uid \
| yq d - metadata.resourceVersion \
| yq d - metadata.creationTimestamp > host-key.yaml
diff-apply "${PREVIEW_K3S_KUBE_CONTEXT}" host-key.yaml
rm -f host-key.yaml
| yq d - metadata.creationTimestamp \
| kubectl --kubeconfig "${PREVIEW_K3S_KUBE_PATH}" --context "${PREVIEW_K3S_KUBE_CONTEXT}" apply -f -

yq w -i "${INSTALLER_CONFIG_PATH}" sshGatewayHostKey.kind "secret"
yq w -i "${INSTALLER_CONFIG_PATH}" sshGatewayHostKey.name "host-key"
Expand Down Expand Up @@ -498,7 +516,7 @@ yq w -i spicedb-secret.yaml metadata.namespace "default"
yq d -i spicedb-secret.yaml metadata.creationTimestamp
yq d -i spicedb-secret.yaml metadata.uid
yq d -i spicedb-secret.yaml metadata.resourceVersion
diff-apply "${PREVIEW_K3S_KUBE_CONTEXT}" spicedb-secret.yaml
kubectl --kubeconfig "${PREVIEW_K3S_KUBE_PATH}" --context "${PREVIEW_K3S_KUBE_CONTEXT}" apply -f spicedb-secret.yaml
rm -f spicedb-secret.yaml

#
Expand Down Expand Up @@ -600,18 +618,7 @@ rm -f /tmp/public-api
log_info "Applying manifests (installing)"

kubectl --kubeconfig "${PREVIEW_K3S_KUBE_PATH}" --context "${PREVIEW_K3S_KUBE_CONTEXT}" delete -n "${PREVIEW_NAMESPACE}" job migrations || true
# export the function so we can use it in xargs
export -f diff-apply
mkdir temp-installer || true
pushd temp-installer
# this will split the big yaml produced by the installer, so we can diff individual parts of it and run them in parallel
yq4 -s '.kind + "_" + .metadata.name' "../${INSTALLER_RENDER_PATH}"
rm .yml || true # this one is a leftover from the split
# shellcheck disable=SC2038
find . | xargs -n 1 -I {} -P 5 bash -c "diff-apply ${PREVIEW_K3S_KUBE_CONTEXT} {}"
log_info "Applied all"
popd
rm -rf temp-installer
kubectl --kubeconfig "${PREVIEW_K3S_KUBE_PATH}" --context "${PREVIEW_K3S_KUBE_CONTEXT}" apply -f "${INSTALLER_RENDER_PATH}"
rm -f "${INSTALLER_RENDER_PATH}"

# =========================
Expand Down
6 changes: 5 additions & 1 deletion dev/preview/workflow/preview/deploy-monitoring-satellite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ kubectl \

echo "Applying generated manifests"
for f in "${manifests_dir}"/*.yaml; do
diff-apply "${PREVIEW_K3S_KUBE_CONTEXT}" "${f}"
echo "Applying $f"
kubectl \
--kubeconfig "${PREVIEW_K3S_KUBE_PATH}" \
--context "${PREVIEW_K3S_KUBE_CONTEXT}" \
apply --server-side -f "${f}"
done

echo "Patching grafana deployment"
Expand Down

0 comments on commit 695e528

Please sign in to comment.