Closed BaeKY closed 1 year ago
deploy-manifest.sh
#!/bin/bash
MANIFESTS=$1
case $MANIFESTS in
-*|--*|'')
echo "Unknown k8s manifest path '$MANIFESTS'"
exit 1
;;
esac
shift
if [ -d $MANIFESTS ]; then
MANIFESTS=$(realpath $MANIFESTS)/*
elif [ ! -f $MANIFESTS ]; then
echo "Files not exists"
exit 1
fi
POSITIONAL_ARGS=()
while [[ $# -gt 0 ]]; do
case $1 in
-w|--wait-crd-creation)
WAIT_CRD_CREATION="$2"
shift # past argument
shift # past value
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done
set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters
cat $(ls $MANIFESTS | grep '.yaml') | yq '. | select(.kind == "CustomResourceDefinition")' | kubectl apply -f -
sleep $WAIT_CRD_CREATION
cat $(ls $MANIFESTS | grep '.yaml') | yq '. | select(.kind != "CustomResourceDefinition")' | kubectl apply -f -
./manifest/0000-metallb.k8s.yaml
를 배포한다
# cd <root>/chart
bash ./scripts/deploy-manifest.sh ./manifest/0000-metallb.k8s.yaml --wait-crd-creation 30
customresourcedefinition.apiextensions.k8s.io/addresspools.metallb.io created
customresourcedefinition.apiextensions.k8s.io/bfdprofiles.metallb.io created
customresourcedefinition.apiextensions.k8s.io/bgpadvertisements.metallb.io created
customresourcedefinition.apiextensions.k8s.io/bgppeers.metallb.io created
customresourcedefinition.apiextensions.k8s.io/ipaddresspools.metallb.io created
customresourcedefinition.apiextensions.k8s.io/l2advertisements.metallb.io created
customresourcedefinition.apiextensions.k8s.io/communities.metallb.io created
serviceaccount/l2-lb-metallb-controller created
serviceaccount/l2-lb-metallb-speaker created
secret/webhook-server-cert created
clusterrole.rbac.authorization.k8s.io/l2-lb-metallb:controller created
clusterrole.rbac.authorization.k8s.io/l2-lb-metallb:speaker created
clusterrolebinding.rbac.authorization.k8s.io/l2-lb-metallb:controller created
clusterrolebinding.rbac.authorization.k8s.io/l2-lb-metallb:speaker created
role.rbac.authorization.k8s.io/l2-lb-metallb-pod-lister created
role.rbac.authorization.k8s.io/l2-lb-metallb-controller created
rolebinding.rbac.authorization.k8s.io/l2-lb-metallb-pod-lister created
rolebinding.rbac.authorization.k8s.io/l2-lb-metallb-controller created
service/metallb-webhook-service created
daemonset.apps/l2-lb-metallb-speaker created
deployment.apps/l2-lb-metallb-controller created
validatingwebhookconfiguration.admissionregistration.k8s.io/metallb-webhook-configuration created
Error from server (InternalError): error when creating "STDIN": Internal error occurred: failed calling webhook "ipaddresspoolvalidationwebhook.metallb.io": failed to call webhook: Post "https://metallb-webhook-service.metallb-system.svc:443/validate-metallb-io-v1beta1-ipaddresspool?timeout=10s": dial tcp 10.103.248.228:443: connect: connection refused
Internal error occurred: failed calling webhook "ipaddresspoolvalidationwebhook.metallb.io": ~~~~~~~~~~
에러로그를 잘 확인하자...
pnpm k8s:deploy ./manifest/0000-metallb.k8s.yaml --wait 17 --resources IPAddressPool
결과: 성공
> @kube-ops/chart@1.0.0 k8s:deploy /Users/bky/dev-private/k8s-lab/chart
> ./scripts/deploy-manifest.sh $@ "./manifest/0000-metallb.k8s.yaml" "--wait" "17" "--resources" "IPAddressPool"
IPAddressPool
serviceaccount/l2-lb-metallb-controller created
serviceaccount/l2-lb-metallb-speaker created
secret/webhook-server-cert created
customresourcedefinition.apiextensions.k8s.io/addresspools.metallb.io created
customresourcedefinition.apiextensions.k8s.io/bfdprofiles.metallb.io created
customresourcedefinition.apiextensions.k8s.io/bgpadvertisements.metallb.io created
customresourcedefinition.apiextensions.k8s.io/bgppeers.metallb.io created
customresourcedefinition.apiextensions.k8s.io/ipaddresspools.metallb.io created
customresourcedefinition.apiextensions.k8s.io/l2advertisements.metallb.io created
customresourcedefinition.apiextensions.k8s.io/communities.metallb.io created
clusterrole.rbac.authorization.k8s.io/l2-lb-metallb:controller created
clusterrole.rbac.authorization.k8s.io/l2-lb-metallb:speaker created
clusterrolebinding.rbac.authorization.k8s.io/l2-lb-metallb:controller created
clusterrolebinding.rbac.authorization.k8s.io/l2-lb-metallb:speaker created
role.rbac.authorization.k8s.io/l2-lb-metallb-pod-lister created
role.rbac.authorization.k8s.io/l2-lb-metallb-controller created
rolebinding.rbac.authorization.k8s.io/l2-lb-metallb-pod-lister created
rolebinding.rbac.authorization.k8s.io/l2-lb-metallb-controller created
service/metallb-webhook-service created
daemonset.apps/l2-lb-metallb-speaker created
deployment.apps/l2-lb-metallb-controller created
validatingwebhookconfiguration.admissionregistration.k8s.io/metallb-webhook-configuration created
ipaddresspool.metallb.io/local-ip created
감사합니다. metallb 최신 버전 에러 발생 이유가 배포 순서 때문이었군요....
kfilt
yq
로도 충분히 가능할것 같다yq
아래와 같이 하면 동작할것 같은데...
kubectl wait --for condition=~~~
해서 하는것 보다 간단할듯.