Skip to content

Revert "Apply gitpod resources if there's diff (#16517)" #16642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2023
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: 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