Skip to content

Commit

Permalink
feat: Add images and demo script for in-cluster registry (#801)
Browse files Browse the repository at this point in the history
Would love it if someone would try it out locally and tell me it works
for them too!
  • Loading branch information
jimmidyson authored Nov 6, 2024
1 parent bfe7bb8 commit f6f0747
Show file tree
Hide file tree
Showing 18 changed files with 1,127 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ eval "$(devbox generate direnv --print-envrc)"

# check out https://www.jetpack.io/devbox/docs/ide_configuration/direnv/
# for more details

source_env_if_exists .envrc.local
2 changes: 1 addition & 1 deletion .github/workflows/checks-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
NIX_USER_COUNT: 4
- name: Build
run: |
GORELEASER_PLATFORMS="\"darwin_amd64\"" devbox run -- task build:release-unpublished
GORELEASER_PLATFORMS='"darwin_amd64"' devbox run -- task build:release-unpublished
- name: Run binary
run: |
./dist/mindthegap_darwin_amd64_v1/mindthegap
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ dist/

.task
.devbox

.envrc.local
kubeconfig
115 changes: 113 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ release:
builds:
- id: mindthegap
dir: ./cmd/mindthegap
main: ./cmd/mindthegap
env:
- CGO_ENABLED=0
flags:
Expand All @@ -49,6 +49,84 @@ builds:
- amd64
- arm64
mod_timestamp: '{{ .CommitTimestamp }}'
hooks:
post:
- |
sh -ec 'if [ {{ .IsSnapshot }} == true ] && [ {{ .Runtime.Goarch }} == {{ .Arch }} ]; then
env SOURCE_DATE_EPOCH=$(date +%s) \
KO_DATA_DATE_EPOCH=$(date +%s) \
KO_DOCKER_REPO=ko.local/mindthegap \
ko build \
--bare \
--platform linux/{{ .Arch }} \
-t v{{ trimprefix .Version "v" }}-{{ .Arch }} \
./cmd/mindthegap
fi'
- id: wait-for-file-to-exist
dir: ./cmd/wait-for-file-to-exist
binary: wait-for-file-to-exist
env:
- CGO_ENABLED=0
flags:
- -trimpath
ldflags:
- -s
- -w
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
mod_timestamp: '{{ .CommitTimestamp }}'
hooks:
post:
- |
sh -ec 'if [ {{ .IsSnapshot }} == true ] && [ {{ .Runtime.Goarch }} == {{ .Arch }} ]; then
cd ./cmd/wait-for-file-to-exist && \
env SOURCE_DATE_EPOCH=$(date +%s) \
KO_DATA_DATE_EPOCH=$(date +%s) \
KO_DOCKER_REPO=ko.local/wait-for-file-to-exist \
KO_DEFAULTBASEIMAGE=cgr.dev/chainguard/busybox \
ko build \
--bare \
--platform linux/{{ .Arch }} \
-t v{{ trimprefix .Version "v" }}-{{ .Arch }} \
.
fi'
- id: copy-file-to-pod
dir: ./cmd/copy-file-to-pod
binary: copy-file-to-pod
env:
- CGO_ENABLED=0
flags:
- -trimpath
ldflags:
- -s
- -w
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
mod_timestamp: '{{ .CommitTimestamp }}'
hooks:
post:
- |
sh -ec 'if [ {{ .IsSnapshot }} == true ] && [ {{ .Runtime.Goarch }} == {{ .Arch }} ]; then
cd ./cmd/copy-file-to-pod && \
env SOURCE_DATE_EPOCH=$(date +%s) \
KO_DATA_DATE_EPOCH=$(date +%s) \
KO_DOCKER_REPO=ko.local/copy-file-to-pod \
ko build \
--bare \
--platform linux/{{ .Arch }} \
-t v{{ trimprefix .Version "v" }}-{{ .Arch }} \
.
fi'
upx:
- enabled: "{{ not .IsSnapshot }}"
Expand All @@ -71,6 +149,8 @@ archives:
format: zip
builds:
- mindthegap
- wait-for-file-to-exist
- copy-file-to-pod

kos:
- id: mindthegap
Expand All @@ -88,9 +168,40 @@ kos:
bare: true
tags:
- v{{trimprefix .Version "v"}}
- id: wait-for-file-to-exist
build: wait-for-file-to-exist
labels:
org.opencontainers.image.created: "{{ .CommitDate }}"
org.opencontainers.image.title: wait-for-file-to-exist
org.opencontainers.image.revision: "{{ .FullCommit }}"
org.opencontainers.image.version: v{{trimprefix .Version "v"}}
org.opencontainers.image.source: "{{ .GitURL }}"
platforms:
- linux/amd64
- linux/arm64
repository: ghcr.io/mesosphere/wait-for-file-to-exist
base_image: cgr.dev/chainguard/busybox
bare: true
tags:
- v{{trimprefix .Version "v"}}
- id: copy-file-to-pod
build: copy-file-to-pod
labels:
org.opencontainers.image.created: "{{ .CommitDate }}"
org.opencontainers.image.title: copy-file-to-pod
org.opencontainers.image.revision: "{{ .FullCommit }}"
org.opencontainers.image.version: v{{trimprefix .Version "v"}}
org.opencontainers.image.source: "{{ .GitURL }}"
platforms:
- linux/amd64
- linux/arm64
repository: ghcr.io/mesosphere/copy-file-to-pod
bare: true
tags:
- v{{trimprefix .Version "v"}}

checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incminor .Tag }}-dev"
version_template: "{{ incminor .Tag }}-dev"
report_sizes: true
84 changes: 84 additions & 0 deletions cmd/copy-file-to-pod/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Copyright 2021 D2iQ, Inc. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

module github.com/nutanix-cloud-native/copy-file-to-pod

go 1.23.2

require (
k8s.io/cli-runtime v0.31.2
k8s.io/kubectl v0.31.2
)

require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
github.com/fatih/camelcase v1.0.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/moby/spdystream v0.4.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.31.2 // indirect
k8s.io/apimachinery v0.31.2 // indirect
k8s.io/client-go v0.31.2 // indirect
k8s.io/component-base v0.31.2 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kustomize/api v0.17.2 // indirect
sigs.k8s.io/kustomize/kyaml v0.17.1 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit f6f0747

Please sign in to comment.