Skip to content

Instantly share code, notes, and snippets.

@khrisrichardson
Last active September 6, 2021 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khrisrichardson/0e65bd08b6c9c56df96b02fcfa535b8a to your computer and use it in GitHub Desktop.
Save khrisrichardson/0e65bd08b6c9c56df96b02fcfa535b8a to your computer and use it in GitHub Desktop.
ARG DOCKER_IO_ALPINE_HELM
ARG DOCKER_IO_GOLANG
ARG GHCR_IO_FLUXCD_KUSTOMIZE_CONTROLLER
#
# helm/helm bin
#
FROM docker.io/alpine/helm:${DOCKER_IO_ALPINE_HELM} as helm
#
# fluxcd/kustomize-controller bin
#
FROM docker.io/golang:${DOCKER_IO_GOLANG} as bin
ARG GITHUB_COM_FLUXCD_KUSTOMIZE_CONTROLLER
ARG PKGS_ALPINELINUX_ORG_PACKAGE_V3_14_MAIN_GIT
ENV CGO_ENABLED 0
ENV GOFLAGS "-ldflags=-s -ldflags=-w"
WORKDIR /go/src/github.com/fluxcd
RUN apk add --no-cache \
git=${PKGS_ALPINELINUX_ORG_PACKAGE_V3_14_MAIN_GIT} && \
git config --global advice.detachedHead false && \
git clone https://github.com/fluxcd/kustomize-controller \
-b ${GITHUB_COM_FLUXCD_KUSTOMIZE_CONTROLLER}
WORKDIR /go/src/github.com/fluxcd/kustomize-controller
RUN sed -i \
-e 's#\(LoadRestrictions:.*\)kustypes.LoadRestrictionsNone,#\1kustypes.LoadRestrictionsRootOnly,#' \
-e 's#\(PluginConfig:.*\)kustypes.DisabledPluginConfig(),#\1kustypes.EnabledPluginConfig(kustypes.BploUseStaticallyLinked),#' \
-e 's#\(k := krusty.MakeKustomizer(buildOptions)\)#buildOptions.PluginConfig.FnpLoadingOptions.Network = true; \1#' ./controllers/kustomization_generator.go && \
go build -a -o "${GOPATH}"/bin/kustomize-controller main.go
#
# fluxcd/kustomize-controller runtime
#
FROM ghcr.io/fluxcd/kustomize-controller:${GHCR_IO_FLUXCD_KUSTOMIZE_CONTROLLER}
ARG PKGS_ALPINELINUX_ORG_PACKAGE_V3_14_COMMUNITY_DOCKER_CLI
ARG PKGS_ALPINELINUX_ORG_PACKAGE_V3_14_MAIN_GIT
ENV GOPATH /go
# hadolint ignore=DL3002
USER root
WORKDIR /usr/local/bin
COPY --from=bin ${GOPATH}/bin/kustomize-controller .
COPY --from=helm /usr/bin/helm ./helmV3
RUN apk add --no-cache \
docker-cli=${PKGS_ALPINELINUX_ORG_PACKAGE_V3_14_COMMUNITY_DOCKER_CLI} \
git=${PKGS_ALPINELINUX_ORG_PACKAGE_V3_14_MAIN_GIT}
apiVersion: apps/v1
kind: Deployment
metadata:
name: kustomize-controller
namespace: flux-system
spec:
template:
spec:
containers:
- name: manager
volumeMounts:
- name: var-run-docker-sock
mountPath: /var/run/docker.sock
volumes:
- name: var-run-docker-sock
hostPath:
path: /var/run/docker.sock
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- gotk-components.yaml
- gotk-sync.yaml
images:
- name: ghcr.io/fluxcd/kustomize-controller
digest: sha256:a6e0f35389495ab9b13f1ed6268142594018ad6962c93be2f0bdd4bffc5dcce2 # replace with your custom image digest
newName: registry.eie.io/fluxcd/kustomize-controller # replace with your custom image name
patchesStrategicMerge:
- gotk-patches.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment