diff --git a/Makefile b/Makefile index ab4ad25..51a2cf0 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,13 @@ # Image URL to use all building/pushing image targets; # Use your own docker registry and image name for dev/test by overridding the # IMAGE_REPO, IMAGE_NAME and IMAGE_TAG environment variable. -IMAGE_REPO ?= docker.io/morvencao +IMAGE_REPO ?= 584416962002.dkr.ecr.us-west-2.amazonaws.com/nginx IMAGE_NAME ?= sidecar-injector + # Github host to use for checking the source tree; # Override this variable ue with your own value if you're working on forked repo. -GIT_HOST ?= github.com/morvencao +GIT_HOST ?= github.com/yahavb PWD := $(shell pwd) BASE_DIR := $(shell basename $(PWD)) @@ -20,7 +21,17 @@ DEST := $(GOPATH)/src/$(GIT_HOST)/$(BASE_DIR) IMAGE_TAG ?= $(shell date +v%Y%m%d)-$(shell git describe --match=$(git rev-parse --short=8 HEAD) --tags --always --dirty) +ARCH := $(shell uname -m) +ifeq ($(ARCH),x86_64) + GOARCH ?= amd64 +else ifeq ($(ARCH),aarch64) + GOARCH ?= arm64 +else + $(error "This system's arch $(ARCH) isn't recognized/supported") +endif + LOCAL_OS := $(shell uname) + ifeq ($(LOCAL_OS),Linux) TARGET_OS ?= linux XARGS_FLAGS="-r" @@ -66,12 +77,12 @@ test: ############################################################ build: - @echo "Building the $(IMAGE_NAME) binary..." + @echo "Building the $(IMAGE_NAME) binary for $(GOARCH)..." @CGO_ENABLED=0 go build -o build/_output/bin/$(IMAGE_NAME) ./cmd/ build-linux: - @echo "Building the $(IMAGE_NAME) binary for Docker (linux)..." - @GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o build/_output/linux/bin/$(IMAGE_NAME) ./cmd/ + @echo "Building the $(IMAGE_NAME) binary for Docker (linux) $(GOARCH)..." + @GOOS=linux GOARCH=$(GOARCH) CGO_ENABLED=0 go build -o build/_output/linux/bin/$(IMAGE_NAME) ./cmd/ ############################################################ # image section diff --git a/build/Dockerfile b/build/Dockerfile index 2a94854..52b8dc9 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,7 +1,7 @@ -FROM alpine:latest +FROM arm64v8/alpine:latest # set labels for metadata -LABEL maintainer="Morven Cao" \ +LABEL maintainer="Yahav Biran" \ name="sidecar-injector" \ description="A Kubernetes mutating webhook server that implements sidecar injection" \ summary="A Kubernetes mutating webhook server that implements sidecar injection" diff --git a/deploy/configmap.yaml b/deploy/configmap.yaml index c30eb1c..7e41044 100644 --- a/deploy/configmap.yaml +++ b/deploy/configmap.yaml @@ -2,7 +2,6 @@ apiVersion: v1 kind: ConfigMap metadata: name: sidecar-injector-webhook-configmap - namespace: sidecar-injector data: sidecarconfig.yaml: | containers: diff --git a/deploy/deployment.yaml b/deploy/deployment.yaml index 1a2fb32..10f40f2 100644 --- a/deploy/deployment.yaml +++ b/deploy/deployment.yaml @@ -2,7 +2,6 @@ apiVersion: apps/v1 kind: Deployment metadata: name: sidecar-injector-webhook-deployment - namespace: sidecar-injector labels: app: sidecar-injector spec: diff --git a/deploy/mutatingwebhook-ca-bundle.yaml b/deploy/mutatingwebhook-ca-bundle.yaml new file mode 100644 index 0000000..f87c451 --- /dev/null +++ b/deploy/mutatingwebhook-ca-bundle.yaml @@ -0,0 +1,21 @@ +apiVersion: admissionregistration.k8s.io/v1beta1 +kind: MutatingWebhookConfiguration +metadata: + name: sidecar-injector-webhook-cfg + labels: + app: sidecar-injector +webhooks: +- name: sidecar-injector.morven.me + clientConfig: + service: + name: sidecar-injector-webhook-svc + path: "/mutate" + caBundle: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM1ekNDQWMrZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeU1ERXhNakl6TlRFMU1Gb1hEVE15TURFeE1ESXpOVEUxTUZvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlF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FFNFRIQXdud0R4NHIrCjg0eXVaMnhjNnFCa3pLMWpyNk9tenhmOVhBQ1JKUHFFMVJGegotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg== + rules: + - operations: ["CREATE", "UPDATE"] + apiGroups: [""] + apiVersions: ["v1"] + resources: ["pods"] + namespaceSelector: + matchLabels: + sidecar-injection: enabled diff --git a/deploy/nginxconfigmap.yaml b/deploy/nginxconfigmap.yaml index 2f6b4dc..03c1f18 100644 --- a/deploy/nginxconfigmap.yaml +++ b/deploy/nginxconfigmap.yaml @@ -2,7 +2,6 @@ apiVersion: v1 kind: ConfigMap metadata: name: nginx-configmap - namespace: sidecar-injector data: nginx.conf: | worker_processes 1; diff --git a/deploy/service.yaml b/deploy/service.yaml index f48c88d..3d060c6 100644 --- a/deploy/service.yaml +++ b/deploy/service.yaml @@ -2,7 +2,6 @@ apiVersion: v1 kind: Service metadata: name: sidecar-injector-webhook-svc - namespace: sidecar-injector labels: app: sidecar-injector spec: