Skip to content

Commit

Permalink
add containerd config regitry
Browse files Browse the repository at this point in the history
  • Loading branch information
lengrongfu committed May 14, 2023
1 parent 1296bc8 commit 70f7dfd
Show file tree
Hide file tree
Showing 74 changed files with 3,543 additions and 738 deletions.
Binary file added .DS_Store
Binary file not shown.
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: CI
on:
push:
pull_request:

jobs:
golangci:
name: Lint with golangci-lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.19
- uses: golangci/golangci-lint-action@v3
with:
version: v1.49.0
vertify:
name: Vertify import alias, vendor, codegen, crds
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}
WORKSPACE: ${{ github.workspace }}/src/github.com/lengrongfu/runtime-copilot
defaults:
run:
working-directory: ${{ env.WORKSPACE }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
path: ${{ env.WORKSPACE }}
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.19
- run: go mod tidy && go mod vendor
- run: hack/verify-import-aliases.sh
- run: hack/verify-vendor.sh
- run: hack/verify-crds.sh

build:
name: Build binary
needs: vertify
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
# https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.19
- name: Compile
run: make build
test:
name: Unit test
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.19
- run: make test
38 changes: 38 additions & 0 deletions .github/workflows/push-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Push Images
on:
push:
tags:
- v*
branches:
- main
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
# https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
fetch-depth: 0
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Set up qemu
uses: docker/setup-qemu-action@v2
with:
platforms: amd64,arm64
- name: Login registry
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push images
env:
ON_PLUGINS: true
run: |
make docker-buildx
21 changes: 21 additions & 0 deletions .github/workflows/sync-helm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Sync helm
on:
push:
tags:
- v*
branches:
- main
jobs:
chart:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
# https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
fetch-depth: 0
- name: push chart
env:
ON_PLUGINS: true
run: |
make helm-sync
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@

# Go workspace file
go.work
./bin/*
38 changes: 25 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

# Image URL to use all building/pushing image targets
IMG ?= controller:latest
DAEMON_IMG ?= ghcr.io/lengrongfu/runtime-copilot/daemon:latest
COPILOT_IMG ?= ghcr.io/lengrongfu/runtime-copilot/controller-manager:latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.26.1

Expand Down Expand Up @@ -62,39 +63,45 @@ test: manifests generate fmt vet envtest ## Run tests.

.PHONY: build
build: manifests generate fmt vet ## Build manager binary.
go build -o bin/manager cmd/main.go
go build -o bin/daemon cmd/daemon/main.go
go build -o bin/copilot cmd/copilot/main.go

.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
go run ./cmd/main.go
go run ./cmd/copilot/main.go

# If you wish built the manager image targeting other platforms you can use the --platform flag.
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
docker build -t ${IMG} .
docker build -t ${COPILOT_IMG} -f ./builds/copilot/Dockerfile .
docker build -t ${DAEMON_IMG} -f ./builds/daemon/Dockerfile .

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
docker push ${IMG}
docker push ${COPILOT_IMG}
docker push ${DAEMON_IMG}

# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
# To properly provided solutions that supports more than one platform you should use this option.
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
PLATFORMS ?= linux/arm64,linux/amd64
.PHONY: docker-buildx
docker-buildx: test ## Build and push docker image for the manager for cross-platform support
docker-buildx: ## Build and push docker image for the manager for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
- docker buildx create --name project-v3-builder
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' ./builds/copilot/Dockerfile > ./builds/copilot/Dockerfile.cross
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' ./builds/daemon/Dockerfile > ./builds/daemon/Dockerfile.cross
docker buildx create --name project-v3-builder
docker buildx use project-v3-builder
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
- docker buildx rm project-v3-builder
rm Dockerfile.cross
docker buildx build --push --platform=$(PLATFORMS) --tag ${COPILOT_IMG} -f ./builds/copilot/Dockerfile.cross .
docker buildx build --push --platform=$(PLATFORMS) --tag ${DAEMON_IMG} -f ./builds/daemon/Dockerfile.cross .
docker buildx rm project-v3-builder
rm ./builds/copilot/Dockerfile.cross
rm ./builds/daemon/Dockerfile.cross

##@ Deployment

Expand All @@ -112,7 +119,7 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified

.PHONY: deploy
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
cd config/manager && $(KUSTOMIZE) edit set image controller=${COPILOT_IMG}
$(KUSTOMIZE) build config/default | kubectl apply -f -

.PHONY: undeploy
Expand Down Expand Up @@ -155,3 +162,8 @@ $(CONTROLLER_GEN): $(LOCALBIN)
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

##@ helm chart Dependencies
.PHONY: helm-sync
helm-sync: ## Sync the helm chart dependencies
bash ./hack/helm-sync.sh
17 changes: 13 additions & 4 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: my.domain
domain: runtime.copilot.io
layout:
- go.kubebuilder.io/v4
projectName: runtime-copilot
Expand All @@ -12,9 +12,18 @@ resources:
crdVersion: v1
namespaced: true
controller: true
domain: my.domain
group: config.runtime.copilot.io
kind: RegistryConfig
domain: runtime.copilot.io
group: config.registry
kind: RegistryConfigs
path: github.com/lengrongfu/runtime-copilot/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: runtime.copilot.io
group: config.registry
kind: NodeRegistryConfigs
path: github.com/lengrongfu/runtime-copilot/api/v1alpha1
version: v1alpha1
version: "3"
6 changes: 3 additions & 3 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1alpha1 contains API Schema definitions for the config.runtime.copilot.io v1alpha1 API group
// Package v1alpha1 contains API Schema definitions for the config.registry v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=config.runtime.copilot.io.my.domain
// +groupName=config.registry.runtime.copilot.io
package v1alpha1

import (
Expand All @@ -26,7 +26,7 @@ import (

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "config.runtime.copilot.io.my.domain", Version: "v1alpha1"}
GroupVersion = schema.GroupVersion{Group: "config.registry.runtime.copilot.io", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
Loading

0 comments on commit 70f7dfd

Please sign in to comment.