adding files 2
This commit is contained in:
66
k8s/fix-imagepull-secret-command-spec.yaml
Normal file
66
k8s/fix-imagepull-secret-command-spec.yaml
Normal file
@@ -0,0 +1,66 @@
|
||||
version: 0.1
|
||||
component: command
|
||||
timeoutInSeconds: 900
|
||||
shell: bash
|
||||
failImmediatelyOnError: true
|
||||
|
||||
env:
|
||||
variables:
|
||||
APP_NAMESPACE: kagent-demo
|
||||
DEPLOYMENT_NAME: payment-service
|
||||
CONTAINER_NAME: payment-service
|
||||
IMAGE_PULL_SECRET: ocir-secret
|
||||
WAIT_TIMEOUT: 300s
|
||||
|
||||
steps:
|
||||
- type: Command
|
||||
name: Restore valid imagePullSecret
|
||||
command: |
|
||||
case "${DEPLOYMENT_NAME}" in
|
||||
order-service|payment-service|inventory-service)
|
||||
echo "Target deployment is valid: ${DEPLOYMENT_NAME}"
|
||||
;;
|
||||
*)
|
||||
echo "Invalid DEPLOYMENT_NAME=${DEPLOYMENT_NAME}"
|
||||
echo "Allowed values: order-service, payment-service, inventory-service"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "${CONTAINER_NAME}" ]; then
|
||||
CONTAINER_NAME="${DEPLOYMENT_NAME}"
|
||||
fi
|
||||
|
||||
echo "APP_NAMESPACE=${APP_NAMESPACE}"
|
||||
echo "DEPLOYMENT_NAME=${DEPLOYMENT_NAME}"
|
||||
echo "CONTAINER_NAME=${CONTAINER_NAME}"
|
||||
echo "IMAGE_PULL_SECRET=${IMAGE_PULL_SECRET}"
|
||||
|
||||
kubectl patch deployment "${DEPLOYMENT_NAME}" -n "${APP_NAMESPACE}" \
|
||||
--type merge \
|
||||
-p "{
|
||||
\"spec\": {
|
||||
\"template\": {
|
||||
\"spec\": {
|
||||
\"imagePullSecrets\": [
|
||||
{\"name\": \"${IMAGE_PULL_SECRET}\"}
|
||||
],
|
||||
\"containers\": [
|
||||
{
|
||||
\"name\": \"${CONTAINER_NAME}\",
|
||||
\"imagePullPolicy\": \"IfNotPresent\"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}"
|
||||
|
||||
kubectl rollout restart deployment/"${DEPLOYMENT_NAME}" -n "${APP_NAMESPACE}"
|
||||
kubectl rollout status deployment/"${DEPLOYMENT_NAME}" -n "${APP_NAMESPACE}" --timeout="${WAIT_TIMEOUT}"
|
||||
|
||||
- type: Command
|
||||
name: Verify restored image pull
|
||||
command: |
|
||||
kubectl get deployment "${DEPLOYMENT_NAME}" -n "${APP_NAMESPACE}" -o jsonpath='{.spec.template.spec.imagePullSecrets}{"\n"}'
|
||||
kubectl get pods -n "${APP_NAMESPACE}" -o wide
|
||||
Reference in New Issue
Block a user