Commit 08d5b70e authored by Tim Leers's avatar Tim Leers

fix: skip unhealty deployments

parent 8efe0888
......@@ -227,6 +227,7 @@ func (worker *NamespaceWorker) ingBackend2Addrs(
backend net_v1.IngressBackend,
) (addrs []vcl.Address, extName string, extPort string, status update.Status) {
nsLister := worker.listers.svc.Services(namespace)
svc, err := nsLister.Get(backend.Service.Name)
if err != nil {
status = IncompleteIfNotFound(err, "%v", err)
......@@ -560,7 +561,7 @@ func (worker *NamespaceWorker) ings2VCLSpec(ings []*net_v1.Ingress) (
addrs, extName, extPort, status := worker.
ingBackend2Addrs(namespace, *backend)
if status.IsError() {
return vclSpec, bcfgs, onlds, status
continue
}
vclSvc, bcfg, onload, status := worker.
getVCLSvc(namespace, backend.Service.Name,
......@@ -599,6 +600,7 @@ func (worker *NamespaceWorker) ings2VCLSpec(ings []*net_v1.Ingress) (
addrs, extName, extPort, status := worker.
ingBackend2Addrs(namespace,
path.Backend)
if status.IsError() {
return vclSpec, bcfgs, onlds, status
}
......
# Copyright (c) 2020 UPLEX Nils Goroll Systemoptimierung
# All rights reserved
#
# Author: Geoffrey Simmons <geoffrey.simmons@uplex.de>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# GNU make is required.
mkpath := $(abspath $(lastword $(MAKEFILE_LIST)))
mkdir := $(dir $(mkpath))
TESTDIR=$(mkdir)/../../../test
all: deploy
deploy-kubectl:
@kubectl create -f cafe.yaml
@kubectl create -f cafe-ingress.yaml
deploy: deploy-kubectl
# TESTOPTS are passed to varnishtest, e.g.: make TESTOPTS=-v verify
verify:
$(mkdir)/verify.sh
wait:
@echo Waiting until varnish-ingress Pods are not configured for Ingress
$(TESTDIR)/wait.sh app=varnish-ingress
uninstall-kubectl:
@kubectl delete -f cafe-ingress.yaml
@kubectl delete -f cafe.yaml
undeploy-kubectl: uninstall-kubectl wait
undeploy: undeploy-kubectl
.PHONY: all $(MAKECMDGOALS)
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: cafe-ingress-varnish
spec:
ingressClassName: viking-controller.uplex.de
rules:
- host: cafe.example.com
http:
paths:
- path: /coffee
pathType: ImplementationSpecific
backend:
service:
name: coffee-svc
port:
number: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: tea-ingress-varnish
spec:
ingressClassName: viking-controller.uplex.de
rules:
- host: tea.example.com
http:
paths:
- path: /tea
pathType: ImplementationSpecific
backend:
service:
name: tea-svc
port:
number: 80
# looks like -*- vcl -*-
varnishtest "cafe example (hello world for Ingress)"
# The beresp may send Connection:close, if Varnish went to pipe due to
# primary-only. So we run each test in a separate connection.
client c1 -connect "${localhost} ${localport}" {
txreq -url /coffee/foo/bar -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 200
expect resp.body ~ "(?m)^URI: /coffee/foo/bar$"
expect resp.body ~ "(?m)^Server name: coffee-[a-z0-9]+-[a-z0-9]+$"
} -run
client c1 -connect "${localhost} ${localport}" {
txreq -url /muckefuck/baz/quux -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 200
expect resp.body ~ "(?m)^URI: /muckefuck/baz/quux$"
expect resp.body ~ "(?m)^Server name: muckefuck-[a-z0-9]+-[a-z0-9]+$"
} -run
client c1 -connect "${localhost} ${localport}" {
txreq -url /coffee/foo/bar
rxresp
expect resp.status == 404
} -run
client c1 -connect "${localhost} ${localport}" {
txreq -url /milk -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 404
} -run
apiVersion: apps/v1
kind: Deployment
metadata:
name: coffee
spec:
replicas: 7
selector:
matchLabels:
app: coffee
template:
metadata:
labels:
app: coffee
spec:
containers:
- name: coffee
image: nginxdemos/hello:plain-text
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: coffee-svc
spec:
ports:
- port: 80
targetPort: 80
protocol: TCP
name: http
selector:
app: coffee
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tea
spec:
replicas: 3
selector:
matchLabels:
app: tea
template:
metadata:
labels:
app: tea
spec:
containers:
- name: tea
image: nginxdemos/hello:plain-text
ports:
- containerPort: 80
command: ["/bin/bash", "-c", "exit 1"]
---
apiVersion: v1
kind: Service
metadata:
name: tea-svc
labels:
spec:
ports:
- port: 80
targetPort: 80
protocol: TCP
name: http
selector:
app: tea
#! /bin/bash -ex
MYDIR=$(dirname ${BASH_SOURCE[0]})
source ${MYDIR}/../../../test/utils.sh
LOCALPORT=${LOCALPORT:-8888}
wait_until_ready app=varnish-ingress
wait_until_configured app=varnish-ingress
kubectl port-forward svc/varnish-ingress ${LOCALPORT}:80 >/dev/null &
trap 'kill $(jobs -p)' EXIT
wait_for_port ${LOCALPORT}
varnishtest ${TESTOPTS} -Dlocalport=${LOCALPORT} cafe.vtc
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment