Skip to content

Commit

Permalink
Docker login before running e2e tests and use shorter names for metri…
Browse files Browse the repository at this point in the history
…cs traffic

Signed-off-by: Furkat Gofurov <furkat.gofurov@suse.com>
  • Loading branch information
furkatgofurov7 committed Nov 18, 2024
1 parent be585c8 commit 5adcfeb
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 20 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
pull_request:

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
test-e2e:
name: Run on Ubuntu
Expand All @@ -17,6 +20,13 @@ jobs:
with:
go-version: '~1.22'

- name: Docker login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Install the latest version of kind
run: |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
Expand Down
14 changes: 6 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Image URL to use all building/pushing image targets
IMG ?= controller:latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.31.0

Expand Down Expand Up @@ -130,17 +128,17 @@ run: manifests generate fmt vet ## Run a controller from your host.
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
.PHONY: docker-build
docker-build: ## Build docker image with the manager.
$(CONTAINER_TOOL) build -t ${IMG} .
$(CONTAINER_TOOL) build -t ${CONTROLLER_IMG}:$(TAG) .

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
$(CONTAINER_TOOL) push ${IMG}
$(CONTAINER_TOOL) push ${CONTROLLER_IMG}:$(TAG)

# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
# architectures. (i.e. make docker-buildx CONTROLLER_IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/
# - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/
# - be able to push the image to your registry (i.e. if you do not set a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
# - be able to push the image to your registry (i.e. if you do not set a valid value via CONTROLLER_IMG=<myregistry/image:<tag>> then the export will fail)
# To adequately provide solutions that are compatible with multiple platforms, you should consider using this option.
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
.PHONY: docker-buildx
Expand All @@ -156,7 +154,7 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
.PHONY: build-installer
build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment.
mkdir -p dist
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
cd config/manager && $(KUSTOMIZE) edit set image controller=${CONTROLLER_IMG}
$(KUSTOMIZE) build config/default > dist/install.yaml

##@ Deployment
Expand All @@ -175,7 +173,7 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified

.PHONY: deploy
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
# cd config/manager && $(KUSTOMIZE) edit set image controller=${CONTROLLER_IMG}
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -

.PHONY: build-kustomize
Expand Down
2 changes: 1 addition & 1 deletion config/certmanager/certificate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
issuerRef:
kind: Issuer
name: selfsigned-issuer
secretName: capi-webhook-service-cert # this secret will not be prefixed, since it's not managed by kustomize
secretName: webhook-server-cert # this secret will not be prefixed, since it's not managed by kustomize
subject:
organizations:
- k8s-sig-cluster-lifecycle
2 changes: 1 addition & 1 deletion config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace: cluster-api-addon-provider-kubewarden-system
# "wordpress" becomes "alices-wordpress".
# Note that it should also match with the prefix (text before '-') of the namespace
# field above.
namePrefix: cluster-api-addon-provider-kubewarden-
namePrefix: capi-provider-kubewarden-

# Labels to add to all resources and selectors.
#labels:
Expand Down
2 changes: 1 addition & 1 deletion config/default/manager_image_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ spec:
template:
spec:
containers:
- image: gcr.io/cluster-api-addon-provider-kubewarden-controller:main
- image: ghcr.io/caapkw/cluster-api-addon-provider-kubewarden:v0.0.1
name: manager
4 changes: 2 additions & 2 deletions config/default/metrics_service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ kind: Service
metadata:
labels:
control-plane: controller-manager
app.kubernetes.io/name: cluster-api-addon-provider-kubewarden
app.kubernetes.io/name: capi-provider-kubewarden
app.kubernetes.io/managed-by: kustomize
name: controller-manager-metrics-service
name: ctrl-mgr-metrics-service
namespace: system
spec:
ports:
Expand Down
2 changes: 1 addition & 1 deletion config/network-policy/allow-metrics-traffic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
labels:
app.kubernetes.io/name: cluster-api-addon-provider-kubewarden
app.kubernetes.io/name: capi-provider-kubewarden
app.kubernetes.io/managed-by: kustomize
name: allow-metrics-traffic
namespace: system
Expand Down
4 changes: 2 additions & 2 deletions config/prometheus/monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ kind: ServiceMonitor
metadata:
labels:
control-plane: controller-manager
app.kubernetes.io/name: cluster-api-addon-provider-kubewarden
app.kubernetes.io/name: capi-provider-kubewarden
app.kubernetes.io/managed-by: kustomize
name: controller-manager-metrics-monitor
name: ctrl-mgr-metrics-monitor
namespace: system
spec:
endpoints:
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ import (
const namespace = "cluster-api-addon-provider-kubewarden-system"

// serviceAccountName created for the project
const serviceAccountName = "cluster-api-addon-provider-kubewarden-controller-manager"
const serviceAccountName = "capi-provider-kubewarden-ctrl-mgr"

// metricsServiceName is the name of the metrics service of the project
const metricsServiceName = "cluster-api-addon-provider-kubewarden-controller-manager-metrics-service"
const metricsServiceName = "capi-provider-kubewarden-ctrl-mgr-metrics-service"

// metricsRoleBindingName is the name of the RBAC that will be created to allow get the metrics data
const metricsRoleBindingName = "cluster-api-addon-provider-kubewarden-metrics-binding"
const metricsRoleBindingName = "capi-provider-kubewarden-metrics-binding"

var _ = Describe("Manager", Ordered, func() {
var controllerPodName string
Expand Down Expand Up @@ -166,7 +166,7 @@ var _ = Describe("Manager", Ordered, func() {
It("should ensure the metrics endpoint is serving metrics", func() {
By("creating a ClusterRoleBinding for the service account to allow access to metrics")
cmd := exec.Command("kubectl", "create", "clusterrolebinding", metricsRoleBindingName,
"--clusterrole=cluster-api-addon-provider-kubewarden-metrics-reader",
"--clusterrole=capi-provider-kubewarden-metrics-reader",
fmt.Sprintf("--serviceaccount=%s:%s", namespace, serviceAccountName),
)
_, err := utils.Run(cmd)
Expand Down

0 comments on commit 5adcfeb

Please sign in to comment.