Skip to content

Commit

Permalink
Merge branch 'master' into wrr-3-annotation-merge-terratest
Browse files Browse the repository at this point in the history
  • Loading branch information
kuritka committed Jul 12, 2022
2 parents 994dc95 + e1af815 commit 5cd7593
Show file tree
Hide file tree
Showing 6 changed files with 212 additions and 5 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/terratest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ jobs:
go-version: "1.17.6"

- name: Build artifacts
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v3
with:
version: v1.7.0
version: v1.9.2
args: release --rm-dist --skip-publish --skip-validate --snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -89,7 +89,14 @@ jobs:
run: |
curl --location --silent --fail --show-error -o terratest_log_parser https://github.com/gruntwork-io/terratest/releases/download/v0.38.8/terratest_log_parser_linux_amd64
chmod +x terratest_log_parser
echo "::group::Parsing the logs"
./terratest_log_parser --testlog ${{ github.workspace }}/tmp/terratest/all.log --outputdir ${{ github.workspace }}/tmp/terratest
echo "::endgroup::"
echo -e "\nSummary:\n--------"
export TERM=xterm
cat ${{ github.workspace }}/tmp/terratest/summary.log | sed -e "s;FAIL;$(tput setaf 1)&$(tput sgr0);" -e "s;PASS;$(tput setaf 2)&$(tput sgr0);"
echo -e "\n\nTerratest logs:"
for log in $(find ${{ github.workspace }}/tmp/terratest -regex ".*/Test.*\.log"); do
echo "::group::$(basename $log)"
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/upgrade-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ jobs:
go-version: "1.17.6"

- name: Build artifacts
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v3
with:
version: v1.7.0
version: v1.9.2
args: release --rm-dist --skip-publish --skip-validate --snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -86,7 +86,14 @@ jobs:
run: |
curl --location --silent --fail --show-error -o terratest_log_parser https://github.com/gruntwork-io/terratest/releases/download/v0.38.8/terratest_log_parser_linux_amd64
chmod +x terratest_log_parser
echo "::group::Parsing the logs"
./terratest_log_parser --testlog ${{ github.workspace }}/tmp/terratest/all.log --outputdir ${{ github.workspace }}/tmp/terratest
echo "::endgroup::"
echo -e "\nSummary:\n--------"
export TERM=xterm
cat ${{ github.workspace }}/tmp/terratest/summary.log | sed -e "s;FAIL;$(tput setaf 1)&$(tput sgr0);" -e "s;PASS;$(tput setaf 2)&$(tput sgr0);"
echo -e "\n\nTerratest logs:"
for log in $(find ${{ github.workspace }}/tmp/terratest -regex ".*/Test.*\.log"); do
echo "::group::$(basename $log)"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ Internal k8gb architecture and its components are described [here](/docs/compone
* [Metrics](/docs/metrics.md)
* [Ingress annotations](/docs/ingress_annotations.md)
* [Integration with Admiralty](/docs/admiralty.md)
* [Integration with Liqo](/docs/liqo.md)

## Production Readiness

Expand Down
2 changes: 1 addition & 1 deletion controllers/gslb_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ func TestCreatesDNSNSRecordsForLoadBalancer(t *testing.T) {
},
}
serviceIPs := []corev1.LoadBalancerIngress{
{IP: "1.1.1.1"}, // rely on 1.1.1.1 response from Cloudflare
{IP: "1.1.1.1"},
}
settings := provideSettings(t, customConfig)
err := settings.client.Create(context.TODO(), coreDNSService)
Expand Down
104 changes: 104 additions & 0 deletions docs/images/gslb-liqo-integration.drawio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions docs/liqo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Integration with Liqo

You can provide powerful global multi-cluster capabilities by combining k8gb and [liqo.io](https://docs.liqo.io).

In this tutorial, you will learn how to leverage Liqo and K8GB to deploy and expose a multi-cluster application through a *global ingress*.
More in detail, this enables improved load balancing and distribution of the external traffic towards the application replicated across multiple clusters.

Liqo will globally schedule workloads and provide east-west connectivity, while K8GB will globally balance user traffic providing north-south connectivity over the multi-cluster and/or multi-provider environment.

The figure below outlines the high-level scenario, with a client consuming an application from either cluster 1 (e.g., located in EU) or cluster 2 (e.g., located in the US), based on the endpoint returned by the DNS server.

![Global Ingress Overview](images/gslb-liqo-integration.drawio.svg)

## Setup Environment

Checkout the [liqo docs](https://docs.liqo.io/en/stable/examples/global-ingress.html) to get the environment setup script and to get more details.
It creates the k3d clusters required for the K8GB playground as described in [Local playground for testing and development](local.md) and installs Liqo over them.

## Peer the clusters

To proceed, first generate a new *peer command* from the *gslb-us* cluster:

```bash
PEER_US=$(liqoctl generate peer-command --only-command --kubeconfig $KUBECONFIG_US)
```

And then, run the generated command from the *gslb-eu* cluster:

```bash
echo "$PEER_US" | bash
```

## Deploy an application

First, create a hosting namespace in the *gslb-eu* cluster, and offload it to the remote cluster through Liqo.

```bash
kubectl create namespace podinfo
liqoctl offload namespace podinfo --namespace-mapping-strategy EnforceSameName
```

At this point, it is possible to deploy the *podinfo* helm chart in the `podinfo` namespace:

```bash
helm upgrade --install podinfo --namespace podinfo podinfo/podinfo \
-f https://raw.githubusercontent.com/liqotech/liqo/master/examples/global-ingress/manifests/values/podinfo.yaml
```

This chart creates a *Deployment* with a *custom affinity* to ensure that the two frontend replicas are scheduled on different nodes and clusters:

```yaml
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/control-plane
operator: DoesNotExist
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
- podinfo
topologyKey: "kubernetes.io/hostname"
```
Additionally, it creates an *Ingress* resource configured with the `k8gb.io/strategy: roundRobin` annotation.
This annotation will [instruct the K8GB Global Ingress Controller](https://www.k8gb.io/docs/ingress_annotations.html) to distribute the traffic across the different clusters.

## Check service reachability

Since *podinfo* is an HTTP service, you can contact it using the *curl* command.
Use the `-v` option to understand which of the nodes is being targeted.

You need to use the DNS server in order to resolve the hostname to the IP address of the service.
To this end, create a pod in one of the clusters (it does not matter which one) overriding its DNS configuration.

```bash
HOSTNAME="liqo.cloud.example.com"
K8GB_COREDNS_IP=$(kubectl get svc k8gb-coredns -n k8gb -o custom-columns='IP:spec.clusterIP' --no-headers)
kubectl run -it --rm curl --restart=Never --image=curlimages/curl:7.82.0 --command \
--overrides "{\"spec\":{\"dnsConfig\":{\"nameservers\":[\"${K8GB_COREDNS_IP}\"]},\"dnsPolicy\":\"None\"}}" \
-- curl $HOSTNAME -v
```

0 comments on commit 5cd7593

Please sign in to comment.