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

Commit

Permalink
update deployment suff
Browse files Browse the repository at this point in the history
  • Loading branch information
maleck13 committed Oct 27, 2023
1 parent 0a3466f commit 583047a
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/policy-controller-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
with:
push: true
tags: ${{ env.IMG_TAGS }}
target: controller
target: policy-controller

- name: Print Image URL
run: |
Expand Down
17 changes: 15 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ COPY pkg/ pkg/
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
FROM builder as controller_builder
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o controller cmd/controller/main.go
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o controller cmd/gateway_controller/main.go

FROM builder as policy_builder
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o policy_controller cmd/policy_controller/main.go

FROM builder as addon_builder
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o add-on-manager cmd/ocm/main.go
Expand All @@ -42,4 +45,14 @@ WORKDIR /
COPY --from=addon_builder /workspace/add-on-manager .
USER 65532:65532

ENTRYPOINT ["/add-on-manager"]
ENTRYPOINT ["/add-on-manager"]


# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot as policy-controller
WORKDIR /
COPY --from=policy_builder /workspace/policy_controller .
USER 65532:65532

ENTRYPOINT ["/policy_controller"]
3 changes: 3 additions & 0 deletions cmd/policy_controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os"

certmanv1 "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
clusterv1 "open-cluster-management.io/api/cluster/v1"

utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/kubernetes/scheme"
Expand Down Expand Up @@ -50,6 +51,8 @@ func init() {
utilruntime.Must(gatewayapi.AddToScheme(scheme.Scheme))
utilruntime.Must(v1alpha1.AddToScheme(scheme.Scheme))
utilruntime.Must(certmanv1.AddToScheme(scheme.Scheme))
//this is need for now but will be removed soon
utilruntime.Must(clusterv1.AddToScheme(scheme.Scheme))
}

func main() {
Expand Down
1 change: 1 addition & 0 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namePrefix: mgc-
resources:
- ../crd
- ../rbac
- namespace.yaml
- ../manager
- ../add-on-manager
- ../policy-controller
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
resources:
- namespace.yaml
- manager.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
Expand Down
4 changes: 2 additions & 2 deletions config/policy-controller/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ spec:
runAsNonRoot: true
containers:
- command:
- /policy-controller
- /policy_controller
args:
- --leader-elect
image: policy-controller:latest
imagePullPolicy: Always
name: manager
name: policy-controller
securityContext:
allowPrivilegeEscalation: false
capabilities:
Expand Down
4 changes: 2 additions & 2 deletions hack/.deployUtils
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ deployOLM(){
kubectl config use-context kind-${clusterName}
kubectl config --kubeconfig=${TMP_DIR}/kubeconfig use-context kind-${clusterName}
echo "Installing OLM in ${clusterName}"
${OPERATOR_SDK_BIN} olm install --timeout 6m0s
${OPERATOR_SDK_BIN} olm install --timeout 10m0s
}


Expand Down Expand Up @@ -110,7 +110,7 @@ deployMetalLB () {
echo "Deploying MetalLB to ${clusterName}"
${KUSTOMIZE_BIN} build ${METALLB_KUSTOMIZATION_DIR} | kubectl apply -f -
echo "Waiting for deployments to be ready ..."
kubectl -n metallb-system wait --for=condition=ready pod --selector=app=metallb --timeout=300s
kubectl -n metallb-system wait --for=condition=ready pod --selector=app=metallb --timeout=600s
configureMetalLB ${clusterName} ${metalLBSubnet}
}

Expand Down
12 changes: 6 additions & 6 deletions hack/make/policy_controller.make
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
##@ Controller
##@ PolicyController

CONTROLLER_IMG ?= policy-controller:$(TAG)
POLICY_CONTROLLER_IMG ?= policy-controller:$(TAG)
LOG_LEVEL ?= 3

.PHONY: build-policy-controller
Expand All @@ -16,20 +16,20 @@ run-policy-controller: manifests generate fmt vet install

.PHONY: docker-build-policy-controller
docker-build-policy-controller: ## Build docker image with the controller.
docker build --target controller -t ${CONTROLLER_IMG} .
docker build --target policy-controller -t ${POLICY_CONTROLLER_IMG} .
docker image prune -f --filter label=stage=mgc-builder

.PHONY: kind-load-policy-controller
kind-load-policy-controller: docker-build-policy-controller
kind load docker-image ${CONTROLLER_IMG} --name mgc-control-plane --nodes mgc-control-plane-control-plane
kind load docker-image ${POLICY_CONTROLLER_IMG} --name mgc-control-plane --nodes mgc-control-plane-control-plane

.PHONY: docker-push-policy-controller
docker-push-policy-controller: ## Push docker image with the controller.
docker push ${CONTROLLER_IMG}
docker push ${POLICY_CONTROLLER_IMG}

.PHONY: deploy-policy-controller
deploy-policy-controller: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/policy-controller && $(KUSTOMIZE) edit set image controller=${CONTROLLER_IMG}
cd config/policy-controller && $(KUSTOMIZE) edit set image controller=${POLICY_CONTROLLER_IMG}
$(KUSTOMIZE) --load-restrictor LoadRestrictionsNone build config/deploy/local | kubectl apply -f -
@if [ $(METRICS) = "true" ]; then\
$(KUSTOMIZE) build config/prometheus | kubectl apply -f -;\
Expand Down

0 comments on commit 583047a

Please sign in to comment.