Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

terratest-bump #3

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/terratest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@ jobs:
uses: AbsaOSS/k3d-action@b176c2a6dcae72e3e64e3e4d61751904ec314002
with:
cluster-name: "edge-dns"
args: -c terratest/deploy/k3d/edge-dns.yaml
args: -c make/deploy/k3d/edge-dns.yaml

- name: Create EU k3s Cluster
uses: AbsaOSS/k3d-action@b176c2a6dcae72e3e64e3e4d61751904ec314002
with:
cluster-name: "k8gb-test-eu"
args: -c terratest/deploy/k3d/k8gb-test-eu.yaml
args: -c make/deploy/k3d/k8gb-test-eu.yaml

- name: Create US k3s Cluster
uses: AbsaOSS/k3d-action@b176c2a6dcae72e3e64e3e4d61751904ec314002
with:
cluster-name: "k8gb-test-us"
args: -c terratest/deploy/k3d/k8gb-test-us.yaml
args: -c make/deploy/k3d/k8gb-test-us.yaml

- name: Create ZA k3s Cluster
uses: AbsaOSS/k3d-action@b176c2a6dcae72e3e64e3e4d61751904ec314002
with:
cluster-name: "k8gb-test-za"
args: -c terratest/deploy/k3d/k8gb-test-za.yaml
args: -c make/deploy/k3d/k8gb-test-za.yaml

- name: K8GB deployment
run: |
Expand Down Expand Up @@ -89,25 +89,25 @@ jobs:
uses: AbsaOSS/k3d-action@b176c2a6dcae72e3e64e3e4d61751904ec314002
with:
cluster-name: "edge-dns"
args: -c terratest/deploy/k3d/edge-dns.yaml
args: -c make/deploy/k3d/edge-dns.yaml

- name: Create EU k3s Cluster on Kubernetes ${{ matrix.kubernetes-version }}
uses: AbsaOSS/k3d-action@b176c2a6dcae72e3e64e3e4d61751904ec314002
with:
cluster-name: "k8gb-test-eu"
args: -c terratest/deploy/k3d/k8gb-test-eu.yaml --image=docker.io/rancher/${{ matrix.kubernetes-version }}
args: -c make/deploy/k3d/k8gb-test-eu.yaml --image=docker.io/rancher/${{ matrix.kubernetes-version }}

- name: Create US k3s Cluster on Kubernetes ${{ matrix.kubernetes-version }}
uses: AbsaOSS/k3d-action@b176c2a6dcae72e3e64e3e4d61751904ec314002
with:
cluster-name: "k8gb-test-us"
args: -c terratest/deploy/k3d/k8gb-test-us.yaml --image=docker.io/rancher/${{ matrix.kubernetes-version }}
args: -c make/deploy/k3d/k8gb-test-us.yaml --image=docker.io/rancher/${{ matrix.kubernetes-version }}

- name: Create ZA k3s Cluster on Kubernetes ${{ matrix.kubernetes-version }}
uses: AbsaOSS/k3d-action@b176c2a6dcae72e3e64e3e4d61751904ec314002
with:
cluster-name: "k8gb-test-za"
args: -c terratest/deploy/k3d/k8gb-test-za.yaml --image=docker.io/rancher/${{ matrix.kubernetes-version }}
args: -c make/deploy/k3d/k8gb-test-za.yaml --image=docker.io/rancher/${{ matrix.kubernetes-version }}

- name: K8GB deployment
run: |
Expand Down
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
!go.sum
!go.mod
!Makefile
!demo.mk
!terratest.mk
!watch.mk
!/make/*.mk
!Dockerfile

# Custromized
/make/*custom.mk
custom.Dockerfile

!README.md
!PROJECT
!LICENSE
Expand All @@ -24,7 +26,7 @@
!.gitkeep
!NOTES.md

!/terratest/deploy/chart/k8gb/**
!/make/deploy/chart/k8gb/**

# ...even if they are in subdirectories
!*/
Expand Down
80 changes: 4 additions & 76 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,14 @@
# limitations under the License.
#
# Generated by GoLic, for more details see: https://github.com/AbsaOSS/golic
BIN := k8gb
REGISTRY = docker.io
REPOSITORY = kuritka
TAG = 932-fix-3
IMG = $(REGISTRY)/$(REPOSITORY)/$(BIN)
SHELL := bash
KEY?=ing
NS?=demo

GOLIC_VERSION ?= v0.7.2
GOKART_VERSION ?= v0.5.1
GOLANGCI_VERSION ?= v1.52.2
MOCKGEN_VERSION ?= v1.6.0

SHELL := bash
TERRATEST_DIR =$(CURDIR)/terratest
DEPLOY_DIR =$(CURDIR)/make/deploy
MAKEIN =make -C .
MAKEAWAY =make -C .


ifndef NO_COLOR
YELLOW=\033[0;33m
Expand All @@ -44,67 +35,4 @@ ifndef GOBIN
GOBIN=$(shell go env GOPATH)/bin
endif

# check integrity
.PHONY: quick-check
quick-check: lint test ## Check project integrity

.PHONY: check
check: mocks gokart build quick-check ## Check project integrity

# updates source code with license headers
.PHONY: license
license:
@echo -e "\n$(YELLOW)Injecting the license$(NC)"
@go install github.com/AbsaOSS/golic@$(GOLIC_VERSION)
$(GOBIN)/golic inject -t apache2

# runs golangci-lint aggregated linter; see .golangci.yaml for linter list
.PHONY: lint
lint:
@echo -e "\n$(YELLOW)Running the linters$(NC)"
goimports -w ./
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_VERSION)
$(GOBIN)/golangci-lint run

.PHONY: build
build:
@echo -e "\n$(YELLOW)Building binary$(NC)"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./k8gb main.go

# run tests
.PHONY: test
test:
@echo -e "\n$(YELLOW)Running the unit tests$(NC)"
go test $$(go list ./... | grep -Ev '/mocks|/terratest|/logging|/tracing') --cover

# GoKart - Go Security Static Analysis
# see: https://github.com/praetorian-inc/gokart
.PHONY: gokart
gokart:
@go install github.com/praetorian-inc/gokart@$(GOKART_VERSION)
@echo "TODO: gokart is not running, fix"
#$(GOBIN)/gokart scan --globalsTainted --verbose

.PHONY: mocks
mocks:
go install github.com/golang/mock/mockgen@$(MOCKGEN_VERSION)
mockgen -package=mocks -destination=controllers/mocks/assistant_mock.go -source=controllers/providers/assistant/assistant.go Assistant
mockgen -package=mocks -destination=controllers/mocks/client_mock.go sigs.k8s.io/controller-runtime/pkg/client Client
mockgen -package=mocks -destination=controllers/mocks/resolver_mock.go -source=controllers/depresolver/resolver.go GslbResolver
mockgen -package=mocks -destination=controllers/mocks/provider_mock.go -source=controllers/providers/dns/dns.go Provider
mockgen -package=mocks -destination=controllers/mocks/mapper_mock.go -source=controllers/mapper/mapper.go Mapper
mockgen -package=mocks -destination=controllers/mocks/mapper_provider_mock.go -source=controllers/mapper/provider.go ProviderMapper
mockgen -package=mocks -destination=controllers/mocks/manager_mock.go sigs.k8s.io/controller-runtime/pkg/manager Manager
mockgen -package=mocks -destination=controllers/mocks/infoblox-client_mock.go -source=controllers/providers/dns/infoblox-client.go InfobloxClient
mockgen -package=mocks -destination=controllers/mocks/infoblox-connection_mock.go github.com/infobloxopen/infoblox-go-client IBConnector
mockgen -package=mocks -destination=controllers/mocks/tracer_mock.go go.opentelemetry.io/otel/trace Tracer
mockgen -package=mocks -destination=controllers/mocks/span_mock.go go.opentelemetry.io/otel/trace Span
mockgen -package=mocks -destination=controllers/mocks/metrics_mock.go -source=controllers/providers/metrics/provider.go Provider
mockgen -package=mapper -destination=controllers/mapper/dig_mock.go -source=controllers/utils/dns.go Digger
mockgen -package=mapper -destination=controllers/mapper/client_mock.go sigs.k8s.io/controller-runtime/pkg/client Client
$(MAKEIN) license

image:
docker build . -t ${IMG}:${TAG}

include ./terratest/terratest.mk
include ./make/*.mk
17 changes: 17 additions & 0 deletions make/cicd.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# cicd.mk contains
BIN := k8gb
REGISTRY = docker.io
REPOSITORY = kuritka
TAG = 932-fix-3
IMG = $(REGISTRY)/$(REPOSITORY)/$(BIN)
OPTIONAL_DOCKERFILE_PATH ?= .

image: build
docker build $(OPTIONAL_DOCKERFILE_PATH) -t $(IMG):$(TAG)

rebuild-k8gb-image:
@echo -e "\n$(YELLOW)Rebuild Image $(CYAN)$(REPOSITORY)/$(BIN):$(TAG) $(NC)"
$(MAKEIN) image

push:
docker push $(IMG):$(TAG)
14 changes: 6 additions & 8 deletions terratest/demo.mk → make/demo.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
TERRATEST_DIR ?=$(CURDIR)

DEFAULT_CONTEXT ?=k3d-k8gb-test-eu

deploy-demo:
Expand All @@ -22,14 +20,14 @@ deploy-demo-%:
--namespace demo

init-failover:
kubectl apply -f $(TERRATEST_DIR)/deploy/demo/fo_demo_ingress.yaml -n demo --context=k3d-k8gb-test-eu
kubectl apply -f $(TERRATEST_DIR)/deploy/demo/fo_demo_ingress.yaml -n demo --context=k3d-k8gb-test-us
kubectl apply -f $(TERRATEST_DIR)/deploy/demo/fo_demo_ingress.yaml -n demo --context=k3d-k8gb-test-za
kubectl apply -f $(DEPLOY_DIR)/deploy/demo/fo_demo_ingress.yaml -n demo --context=k3d-k8gb-test-eu
kubectl apply -f $(DEPLOY_DIR)/deploy/demo/fo_demo_ingress.yaml -n demo --context=k3d-k8gb-test-us
kubectl apply -f $(DEPLOY_DIR)/deploy/demo/fo_demo_ingress.yaml -n demo --context=k3d-k8gb-test-za

init-wrr:
kubectl apply -f $(TERRATEST_DIR)/deploy/demo/wrr_demo_ingress.yaml -n demo --context=k3d-k8gb-test-eu
kubectl apply -f $(TERRATEST_DIR)/deploy/demo/wrr_demo_ingress.yaml -n demo --context=k3d-k8gb-test-us
kubectl apply -f $(TERRATEST_DIR)/deploy/demo/wrr_demo_ingress.yaml -n demo --context=k3d-k8gb-test-za
kubectl apply -f $(DEPLOY_DIR)/deploy/demo/wrr_demo_ingress.yaml -n demo --context=k3d-k8gb-test-eu
kubectl apply -f $(DEPLOY_DIR)/deploy/demo/wrr_demo_ingress.yaml -n demo --context=k3d-k8gb-test-us
kubectl apply -f $(DEPLOY_DIR)/deploy/demo/wrr_demo_ingress.yaml -n demo --context=k3d-k8gb-test-za

kill-local-k8gb:
kubectl config use-context $(DEFAULT_CONTEXT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: k8gb
description: A Helm chart for Kubernetes Global Balancer
icon: https://www.k8gb.io/assets/images/icon-192x192.png
type: application
version: v0.10.0
appVersion: v0.10.0
version: v0.11.1
appVersion: v0.11.1
kubeVersion: ">= 1.19.0-0"

dependencies:
Expand All @@ -22,6 +22,7 @@ keywords:
- kuberneters-global-balancer
- kubernetes-operator
- balancer
- multi-cluster

maintainers:
- email: [email protected]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# k8gb

![Version: v0.10.0](https://img.shields.io/badge/Version-v0.10.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.10.0](https://img.shields.io/badge/AppVersion-v0.10.0-informational?style=flat-square)
![Version: v0.11.1](https://img.shields.io/badge/Version-v0.11.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.11.1](https://img.shields.io/badge/AppVersion-v0.11.1-informational?style=flat-square)

A Helm chart for Kubernetes Global Balancer

Expand All @@ -19,11 +19,11 @@ A Helm chart for Kubernetes Global Balancer

| Name | Email | Url |
| ---- | ------ | --- |
| Dinar Valeev | [email protected] | |
| Jiri Kremser | [email protected] | |
| Michal Kuritka | [email protected] | |
| Timofey Ilinykh | [email protected] | |
| Yury Tsarev | [email protected] | |
| Dinar Valeev | <[email protected]> | |
| Jiri Kremser | <[email protected]> | |
| Michal Kuritka | <[email protected]> | |
| Timofey Ilinykh | <[email protected]> | |
| Yury Tsarev | <[email protected]> | |

## Source Code

Expand Down Expand Up @@ -53,15 +53,15 @@ For Kubernetes `< 1.19` use this chart and k8gb in version `0.8.8` or lower.
|-----|------|---------|-------------|
| coredns.deployment.skipConfig | bool | `true` | Skip CoreDNS creation and uses the one shipped by k8gb instead |
| coredns.image.repository | string | `"absaoss/k8s_crd"` | CoreDNS CRD plugin image |
| coredns.image.tag | string | `"v0.0.8"` | image tag |
| coredns.image.tag | string | `"v0.0.10"` | image tag |
| coredns.isClusterService | bool | `false` | service: refer to https://www.k8gb.io/docs/service_upgrade.html for upgrading CoreDNS service steps |
| coredns.serviceAccount | object | `{"create":true,"name":"coredns"}` | Creates serviceAccount for coredns |
| externaldns.image | string | `"registry.k8s.io/external-dns/external-dns:v0.9.0"` | external-dns image repo:tag |
| externaldns.image | string | `"ghcr.io/k8gb-io/external-dns:v0.13.4-azure-ns"` | external-dns image repo:tag It is important to use the image from k8gb external-dns fork to get the full functionality. See links below https://github.com/k8gb-io/external-dns https://github.com/k8gb-io/external-dns/pkgs/container/external-dns |
| externaldns.interval | string | `"20s"` | external-dns sync interval |
| externaldns.securityContext.fsGroup | int | `65534` | For ExternalDNS to be able to read Kubernetes and AWS token files |
| externaldns.securityContext.runAsNonRoot | bool | `true` | |
| externaldns.securityContext.runAsUser | int | `1000` | For more options consult https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#securitycontext-v1-core |
| global.imagePullSecrets | list | `[]` | Reference to one or more secrets to be used when pulling images ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ |
| global.imagePullSecrets | list | `[]` | Reference to one or more secrets to be used when pulling images ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ |
| infoblox.enabled | bool | `false` | infoblox provider enabled |
| infoblox.gridHost | string | `"10.0.0.1"` | WAPI address |
| infoblox.httpPoolConnections | int | `10` | Size of connections pool |
Expand Down Expand Up @@ -97,9 +97,10 @@ For Kubernetes `< 1.19` use this chart and k8gb in version `0.8.8` or lower.
| rfc2136.rfc2136Opts[1].port | int | `1053` | |
| rfc2136.rfc2136Opts[2].tsig-secret-alg | string | `"hmac-sha256"` | |
| rfc2136.rfc2136Opts[3].tsig-keyname | string | `"externaldns-key"` | |
| route53.assumeRoleArn | string | `nil` | specify IRSA Role in AWS ARN format for assume role permissions or disable it by setting to `null` |
| route53.enabled | bool | `false` | Enable Route53 provider |
| route53.hostedZoneID | string | `"ZXXXSSS"` | Route53 ZoneID |
| route53.irsaRole | string | `"arn:aws:iam::111111:role/external-dns"` | specify IRSA Role in AWS ARN format or disable it by setting to `false` |
| route53.irsaRole | string | `"arn:aws:iam::111111:role/external-dns"` | specify IRSA Role in AWS ARN format or disable it by setting to `null` |
| tracing.deployJaeger | bool | `false` | should the Jaeger be deployed together with the k8gb operator? In case of using another OpenTracing solution, make sure that configmap for OTEL agent has the correct exporters set up (`tracing.otelConfig`). |
| tracing.enabled | bool | `false` | if the application should be sending the traces to OTLP collector (env var `TRACING_ENABLED`) |
| tracing.endpoint | string | `"localhost:4318"` | `host:port` where the spans from the applications (traces) should be sent, sets the `OTEL_EXPORTER_OTLP_ENDPOINT` env var This is not the final destination where all the traces are going. Otel collector has its configuration in the associated configmap (`tracing.otelConfig`). |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ data:
errors
health
ready
loadbalance round_robin
prometheus 0.0.0.0:9153
forward . /etc/resolv.conf
k8s_crd {
resources DNSEndpoint
filter k8gb.absa.oss/dnstype=local
negttl {{ .Values.k8gb.dnsZoneNegTTL }}
loadbalance weight
}
}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ spec:
- --annotation-filter=k8gb.absa.oss/dnstype=extdns # filter out only relevant DNSEntrypoints
- --txt-owner-id={{ include "k8gb.extdnsOwnerID" . }}
- --provider={{ include "k8gb.extdnsProvider" . }}
{{- if .Values.route53.assumeRoleArn }}
- --aws-assume-role={{ .Values.route53.assumeRoleArn }}
{{- end }}
{{ include "k8gb.extdnsProviderOpts" . }}
resources:
requests:
Expand Down
Loading