Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/refactor makefile #68

Merged
merged 1 commit into from
May 24, 2024
Merged
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
17 changes: 0 additions & 17 deletions Dockerfile

This file was deleted.

78 changes: 59 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,37 @@ IMG ?= ovnmaster:latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:crdVersions=v1,generateEmbeddedObjectMeta=true"

IMAGE_TAG := $(shell git rev-parse --short HEAD)
IMAGE_REPOSITORY := ghcr.io/nauti-io


# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif

GIT_COMMIT = $(shell git rev-parse HEAD)
ifeq ($(shell git tag --points-at ${GIT_COMMIT}),)
GIT_VERSION=$(shell echo ${GIT_COMMIT} | cut -c 1-7)
else
GIT_VERSION=$(shell git describe --abbrev=0 --tags --always)
endif

IMAGE_TAG = ${GIT_VERSION}
REGISTRY ?= ghcr.io
REGISTRY_NAMESPACE ?= nauti-io


DOCKERARGS?=
ifdef HTTP_PROXY
DOCKERARGS += --build-arg http_proxy=$(HTTP_PROXY)
endif
ifdef HTTPS_PROXY
DOCKERARGS += --build-arg https_proxy=$(HTTPS_PROXY)
endif

lint: golangci-lint
golangci-lint run -c .golangci.yaml --timeout=10m



# Generate manifests e.g. CRD, RBAC etc.
manifests: controller-gen
$(CONTROLLER_GEN) $(CRD_OPTIONS) paths="./..." output:crd:artifacts:config=deploy/hub/crds/
Expand All @@ -43,29 +58,54 @@ endif


ovnmaster:
CGO_ENABLED=0 GOOS=linux go build -ldflags "-w -s" -a -installsuffix cgo -o cmd/ovnmaster/ovnmaster cmd/ovnmaster/main.go
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags "-w -s" -a -installsuffix cgo -o bin/ovnmaster cmd/ovnmaster/main.go

crossdns:
CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -a -installsuffix cgo -o cmd/crossdns/crossdns cmd/crossdns/main.go
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -a -installsuffix cgo -o bin/crossdns cmd/crossdns/main.go

octopus:
CGO_ENABLED=0 GOOS=linux go build -ldflags "-w -s" -a -installsuffix cgo -o cmd/octopus/octopus cmd/octopus/main.go
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags "-w -s" -a -installsuffix cgo -o bin/octopus cmd/octopus/main.go

dedinic:
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags "-w -s" -a -installsuffix cgo -o bin/dedinic cmd/dedinic/main.go

ep-controller:
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags "-w -s" -a -installsuffix cgo -o bin/ep-controller cmd/ep-controller/main.go

images:
docker build -f ./build/dedinic.Dockerfile ./ -t ${IMAGE_REPOSITORY}/dedinic:${IMAGE_TAG}
docker build -f ./build/ep-controller.Dockerfile ./ -t ${IMAGE_REPOSITORY}/ep-controller:${IMAGE_TAG}
docker push ${IMAGE_REPOSITORY}/dedinic:${IMAGE_TAG}
docker push ${IMAGE_REPOSITORY}/ep-controller:${IMAGE_TAG}

dedinic-image:
docker build -f ./build/dedinic.Dockerfile ./ -t${IMAGE_REPOSITORY}/dedinic:${IMAGE_TAG}
docker push ${IMAGE_REPOSITORY}/dedinic:${IMAGE_TAG}
ep-controller-image:
docker build -f ./build/ep-controller.Dockerfile ./ -t ${IMAGE_REPOSITORY}/ep-controller:${IMAGE_TAG}
docker push ${IMAGE_REPOSITORY}/ep-controller:${IMAGE_TAG}
docker build $(DOCKERARGS) -f ./build/ovnmaster.Dockerfile ./ -t ${REGISTRY}/${REGISTRY_NAMESPACE}/ovnmaster:${IMAGE_TAG}
docker build $(DOCKERARGS) -f ./build/crossdns.Dockerfile ./ -t ${REGISTRY}/${REGISTRY_NAMESPACE}/crossdns:${IMAGE_TAG}
docker build $(DOCKERARGS) -f ./build/octopus.Dockerfile ./ -t ${REGISTRY}/${REGISTRY_NAMESPACE}/octopus:${IMAGE_TAG}
docker build $(DOCKERARGS) -f ./build/dedinic.Dockerfile ./ -t ${REGISTRY}/${REGISTRY_NAMESPACE}/dedinic:${IMAGE_TAG}
docker build $(DOCKERARGS) -f ./build/ep-controller.Dockerfile ./ -t ${REGISTRY}/${REGISTRY_NAMESPACE}/ep-controller:${IMAGE_TAG}

image-ovnmaster:
docker build $(DOCKERARGS) -f ./build/ovnmaster.Dockerfile ./ -t ${REGISTRY}/${REGISTRY_NAMESPACE}/ovnmaster:${IMAGE_TAG}
docker push ${REGISTRY}/${REGISTRY_NAMESPACE}/ovnmaster:${IMAGE_TAG}

image-crossdns:
docker build $(DOCKERARGS) -f ./build/crossdns.Dockerfile ./ -t ${REGISTRY}/${REGISTRY_NAMESPACE}/crossdns:${IMAGE_TAG}
docker push ${REGISTRY}/${REGISTRY_NAMESPACE}/crossdns:${IMAGE_TAG}

image-octopus:
docker build $(DOCKERARGS) -f ./build/octopus.Dockerfile ./ -t ${REGISTRY}/${REGISTRY_NAMESPACE}/octopus:${IMAGE_TAG}
docker push ${REGISTRY}/${REGISTRY_NAMESPACE}/octopus:${IMAGE_TAG}

image-dedinic:
docker build $(DOCKERARGS) -f ./build/dedinic.Dockerfile ./ -t ${REGISTRY}/${REGISTRY_NAMESPACE}/dedinic:${IMAGE_TAG}
docker push ${REGISTRY}/${REGISTRY_NAMESPACE}/dedinic:${IMAGE_TAG}

image-ep-controller:
docker build $(DOCKERARGS) -f ./build/ep-controller.Dockerfile ./ -t ${REGISTRY}/${REGISTRY_NAMESPACE}/ep-controller:${IMAGE_TAG}
docker push ${REGISTRY}/${REGISTRY_NAMESPACE}/ep-controller:${IMAGE_TAG}


images-push:
docker push ${REGISTRY}/${REGISTRY_NAMESPACE}/ovnmaster:${IMAGE_TAG}
docker push ${REGISTRY}/${REGISTRY_NAMESPACE}/crossdns:${IMAGE_TAG}
docker push ${REGISTRY}/${REGISTRY_NAMESPACE}/octopus:${IMAGE_TAG}
docker push ${REGISTRY}/${REGISTRY_NAMESPACE}/dedinic:${IMAGE_TAG}
docker push ${REGISTRY}/${REGISTRY_NAMESPACE}/ep-controller:${IMAGE_TAG}

# find or download golangci-lint
# download golangci-lint if necessary
Expand Down
16 changes: 16 additions & 0 deletions build/crossdns.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM golang:1.21-alpine as builder

WORKDIR /workspace
RUN apk add make
COPY ../go.mod ../go.sum ./
COPY ../staging/ ./staging
RUN go mod download
COPY .. .
RUN make crossdns


FROM scratch

COPY --from=builder /workspace/bin/crossdns /
EXPOSE 53 53/udp
ENTRYPOINT "/crossdns"
15 changes: 15 additions & 0 deletions build/octopus.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.21-alpine as builder

WORKDIR /workspace
RUN apk add make
COPY ../go.mod ../go.sum ./
COPY ../staging/ ./staging
RUN go mod download
COPY .. .
RUN make octopus


FROM alpine:3.17.2
RUN apk add --no-cache wireguard-tools bash wget openresolv iptables
COPY --from=builder /workspace/bin/octopus /
ENTRYPOINT "/octopus"
15 changes: 15 additions & 0 deletions build/ovnmaster.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.21-alpine as builder

WORKDIR /workspace
RUN apk add make
COPY ../go.mod ../go.sum ./
COPY ../staging/ ./staging
RUN go mod download
COPY .. .
RUN make ovnmaster


FROM alpine:3.17.2

COPY --from=builder /workspace/bin/ovnmaster /
ENTRYPOINT "/ovnmaster"
2 changes: 1 addition & 1 deletion deploy/cluster/templates/crossdns-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ spec:
- -conf
- /etc/coredns/Corefile
name: crossdns
image: "{{ .Values.image.repository }}/crossdns:{{ .Values.image.tag | default .Chart.AppVersion }}"
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}/crossdns:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
- mountPath: /etc/coredns
Expand Down
6 changes: 3 additions & 3 deletions deploy/cluster/templates/dedinic-ds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ spec:
fieldPath: metadata.namespace
- name: PARALLEL_IP_ANNOTATION
value: "nauti.io/ip_address"
image: {{ .Values.epControllerImage }}
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}/ep-controller:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: Always
resources:
requests:
Expand Down Expand Up @@ -83,9 +83,9 @@ spec:
value: "true"
- name: DBUS_SYSTEM_BUS_ADDRESS
value: unix:path=/host/var/run/dbus/system_bus_socket
image: {{ .Values.dedinicImage }}
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}/dedinic:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: Always
name: cni-server
name: dedinic
resources:
limits:
cpu: "1"
Expand Down
2 changes: 1 addition & 1 deletion deploy/cluster/templates/ovn-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
serviceAccountName: ovn
containers:
- name: ipam-controller
image: "{{ .Values.image.repository }}/ovnmaster:{{ .Values.image.tag | default .Chart.AppVersion }}"
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}/ovnmaster:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: NODE_IPS
Expand Down
4 changes: 2 additions & 2 deletions deploy/cluster/templates/tunnel_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ spec:
spec:
serviceAccountName: {{ .Values.serviceAccount.name }}
containers:
- name: {{ .Chart.Name }}
- name: octopus
securityContext:
privileged: false
capabilities:
add: ["NET_ADMIN", "NET_RAW"]
image: "{{ .Values.image.repository }}/octopus:{{ .Values.image.tag | default .Chart.AppVersion }}"
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}/octopus:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: OCTOPUS_CLUSTERID
Expand Down
8 changes: 3 additions & 5 deletions deploy/cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
image:
repository: lmxia
registry: ghcr.io
repository: nauti-io
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: "v1.0"
epControllerImage: docker.io/airren/ep-controller:latest
dedinicImage: docker.io/airren/dedinic:v1.13.0-debug
tag: "latest"

cluster:
# Specifies whether this is a hub
Expand All @@ -26,7 +25,6 @@ hub:

tunnel:
cidr: ""
globalcidr: 10.112.0.0/12

serviceAccount:
# Specifies whether a service account should be created
Expand Down
4 changes: 2 additions & 2 deletions deploy/hub/templates/tunnel_eployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ spec:
spec:
serviceAccountName: {{ .Values.serviceAccount.name }}
containers:
- name: {{ .Chart.Name }}
- name: octopus
securityContext:
privileged: false
capabilities:
add: ["NET_ADMIN", "NET_RAW"]
image: "{{ .Values.image.repository }}/octopus:{{ .Values.image.tag | default .Chart.AppVersion }}"
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}/octopus:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: OCTOPUS_CLUSTERID
Expand Down
7 changes: 4 additions & 3 deletions deploy/hub/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
image:
repository: lmxia
pullPolicy: IfNotPresent
registry: ghcr.io
repository: nauti-io
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: "v1.0"
tag: "latest"

cluster:
# Specifies whether this is a hub
Expand Down
Loading