added linkerd ingress operator
This commit is contained in:
parent
addd3ea953
commit
fe1523102d
6 changed files with 128 additions and 0 deletions
29
testapp/linkerd-ingress-operator/hooks/ingress-add.sh
Executable file
29
testapp/linkerd-ingress-operator/hooks/ingress-add.sh
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [[ $1 == "--config" ]]; then
|
||||
cat <<EOF
|
||||
{
|
||||
"onKubernetesEvent": [
|
||||
{
|
||||
"kind": "Ingress",
|
||||
"event": ["add"]
|
||||
}
|
||||
]
|
||||
}
|
||||
EOF
|
||||
else
|
||||
json=${BINDING_CONTEXT_PATH}
|
||||
ns=$(jq -r '.[0].resourceNamespace' ${json})
|
||||
res=$(jq -r '.[0].resourceName' ${json})
|
||||
tmp=$(mktemp)
|
||||
kubectl -n "${ns}" get ingress "${res}" -ojson >${tmp} || { echo "error: getting ingress ${ns}/${res} failed">&2; exit 0; }
|
||||
class=$(jq -r '.metadata.annotations."kubernetes.io/ingress.class"' ${tmp})
|
||||
[[ "${class}" == "nginx" ]] || { echo "notice: ingress class ${ns}/${res} is not 'nginx'"; exit 0; }
|
||||
port=$(jq -r '.spec.rules[0].http.paths[0].backend.servicePort' ${tmp})
|
||||
ann=$(jq -r '.metadata.annotations."nginx.ingress.kubernetes.io/configuration-snippet"' ${tmp})
|
||||
rm -f ${tmp}
|
||||
[[ "${ann}" =~ "l5d-dst-override" ]] && { echo "notice: ingress ${ns}/${res} already has 'l5d-dst-override' header"; exit 0; }
|
||||
[[ "${ann}" == "null" ]] && ann="" || ann="${ann}"$'\n'
|
||||
ann="${ann}proxy_set_header l5d-dst-override \$service_name.\$namespace.svc.cluster.local:${port}"$';\nproxy_hide_header l5d-remote-ip;\nproxy_hide_header l5d-server-id;\n'
|
||||
kubectl -n "${ns}" annotate ingress "${res}" nginx.ingress.kubernetes.io/configuration-snippet="${ann}"
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue