Skip to content

Commit

Permalink
Explicit fqdns in roundrobin sample CR
Browse files Browse the repository at this point in the history
* Main motivation is that roundrobin.example.com
is more clear than app3.example.com especially in the demo context

* Rename also app1 and app2 with their semantic
meanings

* Associated mass rename in docs and tests

Signed-off-by: Yury Tsarev <yury.tsarev@absa.africa>
  • Loading branch information
ytsarev committed Jan 11, 2021
1 parent d1d7329 commit 8297ea1
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 62 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ debug-test-etcd: ## Run temporary etcd pod for debug

.PHONY: demo-roundrobin
demo-roundrobin: ## Execute round-robin demo
@$(call demo-host, "app3.cloud.example.com")
@$(call demo-host, "roundrobin.cloud.example.com")

.PHONY: demo-failover
demo-failover: ## Execute failover demo
Expand Down Expand Up @@ -163,7 +163,7 @@ dns-tools: ## Run temporary dnstools pod for debugging DNS issues

.PHONY: dns-smoke-test
dns-smoke-test:
kubectl -n k8gb run -it --rm --restart=Never --image=infoblox/dnstools:latest dnstools --command -- /usr/bin/dig @k8gb-coredns app3.cloud.example.com
kubectl -n k8gb run -it --rm --restart=Never --image=infoblox/dnstools:latest dnstools --command -- /usr/bin/dig @k8gb-coredns roundrobin.cloud.example.com

# build the docker image
.PHONY: docker-build
Expand Down Expand Up @@ -251,7 +251,7 @@ test: lint

.PHONY: test-round-robin
test-round-robin:
@$(call hit-testapp-host, "app3.cloud.example.com")
@$(call hit-testapp-host, "roundrobin.cloud.example.com")

.PHONY: test-failover
test-failover:
Expand Down
6 changes: 3 additions & 3 deletions controllers/depresolver/testdata/filled_omitempty.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ metadata:
spec:
ingress:
rules:
- host: app1.cloud.example.com # This is the GSLB enabled host that clients would use
- host: notfound.cloud.example.com # This is the GSLB enabled host that clients would use
http: # This section mirrors the same structure as that of an Ingress resource and will be used verbatim when creating the corresponding Ingress resource that will match the GSLB host
paths:
- backend:
serviceName: non-existing-app # Gslb should reflect NotFound status
servicePort: http
path: /
- host: app2.cloud.example.com
- host: unhealthy.cloud.example.com
http:
paths:
- backend:
serviceName: unhealthy-app # Gslb should reflect Unhealthy status
servicePort: http
path: /
- host: app3.cloud.example.com
- host: roundrobin.cloud.example.com
http:
paths:
- backend:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ metadata:
spec:
ingress:
rules:
- host: app1.cloud.example.com # This is the GSLB enabled host that clients would use
- host: notfound.cloud.example.com # This is the GSLB enabled host that clients would use
http: # This section mirrors the same structure as that of an Ingress resource and will be used verbatim when creating the corresponding Ingress resource that will match the GSLB host
paths:
- backend:
serviceName: non-existing-app # Gslb should reflect NotFound status
servicePort: http
path: /
- host: app2.cloud.example.com
- host: unhealthy.cloud.example.com
http:
paths:
- backend:
serviceName: unhealthy-app # Gslb should reflect Unhealthy status
servicePort: http
path: /
- host: app3.cloud.example.com
- host: roundrobin.cloud.example.com
http:
paths:
- backend:
Expand Down
6 changes: 3 additions & 3 deletions controllers/depresolver/testdata/free_omitempty.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ metadata:
spec:
ingress:
rules:
- host: app1.cloud.example.com # This is the GSLB enabled host that clients would use
- host: notfound.cloud.example.com # This is the GSLB enabled host that clients would use
http: # This section mirrors the same structure as that of an Ingress resource and will be used verbatim when creating the corresponding Ingress resource that will match the GSLB host
paths:
- backend:
serviceName: non-existing-app # Gslb should reflect NotFound status
servicePort: http
path: /
- host: app2.cloud.example.com
- host: unhealthy.cloud.example.com
http:
paths:
- backend:
serviceName: unhealthy-app # Gslb should reflect Unhealthy status
servicePort: http
path: /
- host: app3.cloud.example.com
- host: roundrobin.cloud.example.com
http:
paths:
- backend:
Expand Down
6 changes: 3 additions & 3 deletions controllers/depresolver/testdata/invalid_omitempty_empty.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ metadata:
spec:
ingress:
rules:
- host: app1.cloud.example.com # This is the GSLB enabled host that clients would use
- host: notfound.cloud.example.com # This is the GSLB enabled host that clients would use
http: # This section mirrors the same structure as that of an Ingress resource and will be used verbatim when creating the corresponding Ingress resource that will match the GSLB host
paths:
- backend:
serviceName: non-existing-app # Gslb should reflect NotFound status
servicePort: http
path: /
- host: app2.cloud.example.com
- host: unhealthy.cloud.example.com
http:
paths:
- backend:
serviceName: unhealthy-app # Gslb should reflect Unhealthy status
servicePort: http
path: /
- host: app3.cloud.example.com
- host: roundrobin.cloud.example.com
http:
paths:
- backend:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ metadata:
spec:
ingress:
rules:
- host: app1.cloud.example.com # This is the GSLB enabled host that clients would use
- host: notfound.cloud.example.com # This is the GSLB enabled host that clients would use
http: # This section mirrors the same structure as that of an Ingress resource and will be used verbatim when creating the corresponding Ingress resource that will match the GSLB host
paths:
- backend:
serviceName: non-existing-app # Gslb should reflect NotFound status
servicePort: http
path: /
- host: app2.cloud.example.com
- host: unhealthy.cloud.example.com
http:
paths:
- backend:
serviceName: unhealthy-app # Gslb should reflect Unhealthy status
servicePort: http
path: /
- host: app3.cloud.example.com
- host: roundrobin.cloud.example.com
http:
paths:
- backend:
Expand Down
6 changes: 3 additions & 3 deletions controllers/fakedns.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ func oldEdgeTimestamp(threshold string) string {
}

var records = map[string][]string{
"localtargets-app3.cloud.example.com.": {"10.1.0.1", "10.1.0.2", "10.1.0.3"},
"test-gslb-heartbeat-eu.example.com.": {oldEdgeTimestamp("10m")},
"test-gslb-heartbeat-za.example.com.": {oldEdgeTimestamp("3m")},
"localtargets-roundrobin.cloud.example.com.": {"10.1.0.1", "10.1.0.2", "10.1.0.3"},
"test-gslb-heartbeat-eu.example.com.": {oldEdgeTimestamp("10m")},
"test-gslb-heartbeat-za.example.com.": {oldEdgeTimestamp("3m")},
}

func parseQuery(m *dns.Msg) {
Expand Down
30 changes: 15 additions & 15 deletions controllers/gslb_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestNotFoundServiceStatus(t *testing.T) {
defer cleanup()
settings := provideSettings(t, predefinedConfig)
expectedServiceStatus := "NotFound"
notFoundHost := "app1.cloud.example.com"
notFoundHost := "notfound.cloud.example.com"
// act
actualServiceStatus := settings.gslb.Status.ServiceHealth[notFoundHost]
// assert
Expand All @@ -86,7 +86,7 @@ func TestUnhealthyServiceStatus(t *testing.T) {
defer cleanup()
settings := provideSettings(t, predefinedConfig)
serviceName := "unhealthy-app"
unhealthyHost := "app2.cloud.example.com"
unhealthyHost := "unhealthy.cloud.example.com"
expectedServiceStatus := "Unhealthy"
defer deleteUnhealthyService(t, &settings, serviceName)
// act
Expand All @@ -104,7 +104,7 @@ func TestHealthyServiceStatus(t *testing.T) {
settings := provideSettings(t, predefinedConfig)
serviceName := "frontend-podinfo"
expectedServiceStatus := "Healthy"
healthyHost := "app3.cloud.example.com"
healthyHost := "roundrobin.cloud.example.com"
defer deleteHealthyService(t, &settings, serviceName)
createHealthyService(t, &settings, serviceName)
reconcileAndUpdateGslb(t, settings)
Expand Down Expand Up @@ -257,12 +257,12 @@ func TestGslbCreatesDNSEndpointCRForHealthyIngressHosts(t *testing.T) {
dnsEndpoint := &externaldns.DNSEndpoint{}
want := []*externaldns.Endpoint{
{
DNSName: "localtargets-app3.cloud.example.com",
DNSName: "localtargets-roundrobin.cloud.example.com",
RecordTTL: 30,
RecordType: "A",
Targets: externaldns.Targets{"10.0.0.1", "10.0.0.2", "10.0.0.3"}},
{
DNSName: "app3.cloud.example.com",
DNSName: "roundrobin.cloud.example.com",
RecordTTL: 30,
RecordType: "A",
Targets: externaldns.Targets{"10.0.0.1", "10.0.0.2", "10.0.0.3"}},
Expand Down Expand Up @@ -298,7 +298,7 @@ func TestDNSRecordReflectionInStatus(t *testing.T) {
defer cleanup()
serviceName := "frontend-podinfo"
dnsEndpoint := &externaldns.DNSEndpoint{}
want := map[string][]string{"app3.cloud.example.com": {"10.0.0.1", "10.0.0.2", "10.0.0.3"}}
want := map[string][]string{"roundrobin.cloud.example.com": {"10.0.0.1", "10.0.0.2", "10.0.0.3"}}
ingressIPs := []corev1.LoadBalancerIngress{
{IP: "10.0.0.1"},
{IP: "10.0.0.2"},
Expand Down Expand Up @@ -373,17 +373,17 @@ func TestCanGetExternalTargetsFromK8gbInAnotherLocation(t *testing.T) {
serviceName := "frontend-podinfo"
want := []*externaldns.Endpoint{
{
DNSName: "localtargets-app3.cloud.example.com",
DNSName: "localtargets-roundrobin.cloud.example.com",
RecordTTL: 30,
RecordType: "A",
Targets: externaldns.Targets{"10.0.0.1", "10.0.0.2", "10.0.0.3"}},
{
DNSName: "app3.cloud.example.com",
DNSName: "roundrobin.cloud.example.com",
RecordTTL: 30,
RecordType: "A",
Targets: externaldns.Targets{"10.0.0.1", "10.0.0.2", "10.0.0.3", "10.1.0.1", "10.1.0.2", "10.1.0.3"}},
}
hrWant := map[string][]string{"app3.cloud.example.com": {"10.0.0.1", "10.0.0.2", "10.0.0.3", "10.1.0.1", "10.1.0.2", "10.1.0.3"}}
hrWant := map[string][]string{"roundrobin.cloud.example.com": {"10.0.0.1", "10.0.0.2", "10.0.0.3", "10.1.0.1", "10.1.0.2", "10.1.0.3"}}
ingressIPs := []corev1.LoadBalancerIngress{
{IP: "10.0.0.1"},
{IP: "10.0.0.2"},
Expand Down Expand Up @@ -487,13 +487,13 @@ func TestReturnsOwnRecordsUsingFailoverStrategyWhenPrimary(t *testing.T) {
serviceName := "frontend-podinfo"
want := []*externaldns.Endpoint{
{
DNSName: "localtargets-app3.cloud.example.com",
DNSName: "localtargets-roundrobin.cloud.example.com",
RecordTTL: 30,
RecordType: "A",
Targets: externaldns.Targets{"10.0.0.1", "10.0.0.2", "10.0.0.3"},
},
{
DNSName: "app3.cloud.example.com",
DNSName: "roundrobin.cloud.example.com",
RecordTTL: 30,
RecordType: "A",
Targets: externaldns.Targets{"10.0.0.1", "10.0.0.2", "10.0.0.3"},
Expand Down Expand Up @@ -542,13 +542,13 @@ func TestReturnsExternalRecordsUsingFailoverStrategy(t *testing.T) {
serviceName := "frontend-podinfo"
want := []*externaldns.Endpoint{
{
DNSName: "localtargets-app3.cloud.example.com",
DNSName: "localtargets-roundrobin.cloud.example.com",
RecordTTL: 30,
RecordType: "A",
Targets: externaldns.Targets{"10.0.0.1", "10.0.0.2", "10.0.0.3"},
},
{
DNSName: "app3.cloud.example.com",
DNSName: "roundrobin.cloud.example.com",
RecordTTL: 30,
RecordType: "A",
Targets: externaldns.Targets{"10.1.0.1", "10.1.0.2", "10.1.0.3"},
Expand Down Expand Up @@ -796,12 +796,12 @@ func TestResolvesLoadBalancerHostnameFromIngressStatus(t *testing.T) {
serviceName := "frontend-podinfo"
want := []*externaldns.Endpoint{
{
DNSName: "localtargets-app3.cloud.example.com",
DNSName: "localtargets-roundrobin.cloud.example.com",
RecordTTL: 30,
RecordType: "A",
Targets: externaldns.Targets{"1.0.0.1", "1.1.1.1"}},
{
DNSName: "app3.cloud.example.com",
DNSName: "roundrobin.cloud.example.com",
RecordTTL: 30,
RecordType: "A",
Targets: externaldns.Targets{"1.0.0.1", "1.1.1.1"}},
Expand Down
6 changes: 3 additions & 3 deletions deploy/crds/k8gb.absa.oss_v1beta1_gslb_cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ metadata:
spec:
ingress:
rules:
- host: app1.cloud.example.com # This is the GSLB enabled host that clients would use
- host: notfound.cloud.example.com # This is the GSLB enabled host that clients would use
http: # This section mirrors the same structure as that of an Ingress resource and will be used verbatim when creating the corresponding Ingress resource that will match the GSLB host
paths:
- backend:
serviceName: non-existing-app # Gslb should reflect NotFound status
servicePort: http
path: /
- host: app2.cloud.example.com
- host: unhealthy.cloud.example.com
http:
paths:
- backend:
serviceName: unhealthy-app # Gslb should reflect Unhealthy status
servicePort: http
path: /
- host: app3.cloud.example.com
- host: roundrobin.cloud.example.com
http:
paths:
- backend:
Expand Down
22 changes: 11 additions & 11 deletions docs/local.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,28 +67,28 @@ eed5a40bbfb6ee97, started, etcd-cluster-xsjmwdkdf8, http://etcd-cluster-xsjmwdkd
Cluster [test-gslb1](https://github.com/AbsaOSS/k8gb/tree/master/deploy/kind/cluster.yaml) is exposing external DNS on default port `:5053`
while [test-gslb2](https://github.com/AbsaOSS/k8gb/tree/master/deploy/kind/cluster2.yaml) on port `:5054`.
```shell script
dig @localhost localtargets-app3.cloud.example.com -p 5053 && dig -p 5054 @localhost localtargets-app3.cloud.example.com
dig @localhost localtargets-roundrobin.cloud.example.com -p 5053 && dig -p 5054 @localhost localtargets-roundrobin.cloud.example.com
```
As expected result you should see **eight A records** divided between nodes of both clusters.
```shell script
...
...
;; ANSWER SECTION:
localtargets-app3.cloud.example.com. 30 IN A 172.16.0.3
localtargets-app3.cloud.example.com. 30 IN A 172.16.0.4
localtargets-app3.cloud.example.com. 30 IN A 172.16.0.2
localtargets-app3.cloud.example.com. 30 IN A 172.16.0.5
localtargets-roundrobin.cloud.example.com. 30 IN A 172.16.0.3
localtargets-roundrobin.cloud.example.com. 30 IN A 172.16.0.4
localtargets-roundrobin.cloud.example.com. 30 IN A 172.16.0.2
localtargets-roundrobin.cloud.example.com. 30 IN A 172.16.0.5
...
...
localtargets-app3.cloud.example.com. 30 IN A 172.16.0.8
localtargets-app3.cloud.example.com. 30 IN A 172.16.0.6
localtargets-app3.cloud.example.com. 30 IN A 172.16.0.7
localtargets-app3.cloud.example.com. 30 IN A 172.16.0.9
localtargets-roundrobin.cloud.example.com. 30 IN A 172.16.0.8
localtargets-roundrobin.cloud.example.com. 30 IN A 172.16.0.6
localtargets-roundrobin.cloud.example.com. 30 IN A 172.16.0.7
localtargets-roundrobin.cloud.example.com. 30 IN A 172.16.0.9
```
Both clusters have [podinfo](https://github.com/stefanprodan/podinfo) installed on the top.
Run following command and check if you get two json responses.
```shell script
curl localhost:80 -H "Host:app3.cloud.example.com" && curl localhost:81 -H "Host:app3.cloud.example.com"
curl localhost:80 -H "Host:roundrobin.cloud.example.com" && curl localhost:81 -H "Host:roundrobin.cloud.example.com"
```

#### Run integration tests
Expand All @@ -112,7 +112,7 @@ make destroy-full-local-setup
### Round Robin

Both clusters have [podinfo](https://github.com/stefanprodan/podinfo) installed on the top, where each
cluster has been tagged to serve a different region. In this demo we will hit podinfo by `wget -qO - app3.cloud.example.com` and depending
cluster has been tagged to serve a different region. In this demo we will hit podinfo by `wget -qO - roundrobin.cloud.example.com` and depending
on region will podinfo return **us** or **eu**. In current round robin implementation are IP addresses randomly picked.
See [Gslb manifest with round robin strategy](https://github.com/AbsaOSS/k8gb/tree/master/deploy/crds/k8gb.absa.oss_v1beta1_gslb_cr.yaml)

Expand Down
6 changes: 3 additions & 3 deletions terratest/examples/ingress-annotation-failover.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ metadata:
name: test-gslb-annotation-failover
spec:
rules:
- host: app1.cloud.example.com
- host: notfound.cloud.example.com
http:
paths:
- backend:
serviceName: non-existing-app
servicePort: http
path: /
- host: app2.cloud.example.com
- host: unhealthy.cloud.example.com
http:
paths:
- backend:
serviceName: unhealthy-app
servicePort: http
path: /
- host: app3.cloud.example.com
- host: roundrobin.cloud.example.com
http:
paths:
- backend:
Expand Down
Loading

0 comments on commit 8297ea1

Please sign in to comment.