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

Control plane #26

Merged
merged 40 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
7c663c7
gitignore
aojea Jun 8, 2024
1139de7
apache license header
aojea Jun 8, 2024
0d70cd3
amake code-generate
aojea Jun 8, 2024
338adcb
scripts to generate code
aojea Jun 8, 2024
ed63cd0
boilerplate configuration api object
aojea Jun 8, 2024
5324f4f
generated code
aojea Jun 8, 2024
2ccd7c5
hack verify
aojea Jun 8, 2024
e6429a1
update hacks
aojea Jun 8, 2024
b6f37cc
make
aojea Jun 8, 2024
b30f13f
make generate
aojea Jun 8, 2024
0f076e5
make update
aojea Jun 8, 2024
a96b3b6
reorganize code
aojea Jun 9, 2024
68caab8
fix indentation
aojea Jun 9, 2024
8195ece
refactor
aojea Jun 9, 2024
617b93e
make update
aojea Jun 9, 2024
0244406
test all
aojea Jun 9, 2024
4a32bb0
generate
aojea Jun 9, 2024
cff9573
add nat64 option
aojea Jun 9, 2024
f2704a6
fix generator
aojea Jun 9, 2024
c1b51bf
remove copyright kubernetes from kindnet
aojea Jun 9, 2024
dafb2b9
add new kindnet controller
aojea Jun 9, 2024
dd29686
configuration must be unique
aojea Jun 9, 2024
cb0746b
build images
aojea Jun 9, 2024
f447df2
document some decisions
aojea Jun 9, 2024
7c7aea4
firs versiion missing CI
aojea Jun 9, 2024
01b3652
setup cI
aojea Jun 10, 2024
65e8a15
fix typo in github action
aojea Jun 10, 2024
a382a67
remove inlinining for the kindnet daemomnset
aojea Jun 10, 2024
6f0d109
wait crd is ready
aojea Jun 10, 2024
f7e5957
wait for the kindnet controller
aojea Jun 10, 2024
a8bc410
default kindnetd image
aojea Jun 10, 2024
5c2585d
add priority class to kindnetd pods
aojea Jun 10, 2024
cac6cb1
refactor kindnet-controler
aojea Jun 10, 2024
b2f4c85
add healthz probe to controller
aojea Jun 10, 2024
7253e7c
fix linter complain
aojea Jun 10, 2024
b20aa74
fixes
aojea Jun 10, 2024
d4bdb17
fix probes
aojea Jun 10, 2024
7212689
fix readiness for kindnet controller
aojea Jun 10, 2024
b9f355b
fix publish images
aojea Jun 10, 2024
ed29341
update job permissions
aojea Jun 10, 2024
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
57 changes: 49 additions & 8 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ env:
KIND_VERSION: "v0.22.0"
KIND_CLUSTER_NAME: "kindnet"
REGISTRY: ghcr.io
IMAGE_NAME: aojea/kindnetd

jobs:
build:
Expand All @@ -34,15 +33,22 @@ jobs:

- name: Build
run: |
docker build -t ghcr.io/aojea/kindnetd:test -f Dockerfile .
docker build -t ghcr.io/aojea/kindnetd:test -f Dockerfile.kindnetd .
docker build -t ghcr.io/aojea/kindnet-controller:test -f Dockerfile.kindnet-controller .
mkdir _output
docker save ghcr.io/aojea/kindnetd:test > _output/kindnetd-image.tar
docker save ghcr.io/aojea/kindnet-controller:test > _output/kindnet-controller-image.tar

- uses: actions/upload-artifact@v2
with:
name: test-image
path: _output/kindnetd-image.tar

- uses: actions/upload-artifact@v2
with:
name: test-image-controller
path: _output/kindnet-controller-image.tar

e2e:
name: e2e
runs-on: ubuntu-latest
Expand Down Expand Up @@ -110,21 +116,31 @@ jobs:
with:
name: test-image

- uses: actions/download-artifact@v2
with:
name: test-image-controller

- name: Install kindnetd
run: |
# preload kindnetd image
docker load --input kindnetd-image.tar
/usr/local/bin/kind load docker-image ghcr.io/aojea/kindnetd:test --name ${{ env.KIND_CLUSTER_NAME}}
# preload kindnet-controller image
docker load --input kindnet-controller-image.tar
/usr/local/bin/kind load docker-image ghcr.io/aojea/kindnet-controller:test --name ${{ env.KIND_CLUSTER_NAME}}

- name: install ptp plugin
run: |
sed -i s#aojea/kindnetd.*#aojea/kindnetd:test# install-kindnet.yaml
sed -i s#aojea/kindnet-controller.*#aojea/kindnet-controller:test# install-kindnet.yaml
sed -i s#aojea/kindnetd.*#aojea/kindnetd:test# docs/default-configuration.yaml
/usr/local/bin/kubectl apply -f ./install-kindnet.yaml

- name: Get Cluster status
run: |
# wait network is ready
sleep 5
# wait kindnet-controller is ready
/usr/local/bin/kubectl wait --timeout=1m --for=condition=ready pods --namespace=kube-system -l app=kindnet-controller
/usr/local/bin/kubectl apply -f ./docs/default-configuration.yaml
# wait network is ready, kube-dns pods depend on the network
/usr/local/bin/kubectl get nodes -o wide
/usr/local/bin/kubectl get pods -A
/usr/local/bin/kubectl wait --timeout=1m --for=condition=ready pods --namespace=kube-system -l k8s-app=kube-dns
Expand Down Expand Up @@ -195,6 +211,7 @@ jobs:
path: ./_artifacts/logs

publish:
permissions: write-all
name: publish
runs-on: ubuntu-latest
timeout-minutes: 10
Expand All @@ -208,6 +225,10 @@ jobs:
with:
name: test-image

- uses: actions/download-artifact@v2
with:
name: test-image-controller

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
Expand All @@ -219,13 +240,18 @@ jobs:
docker load --input kindnetd-image.tar
docker tag ghcr.io/aojea/kindnetd:test aojea/kindnetd
docker push aojea/kindnetd
docker load --input kindnet-controller-image.tar
docker tag ghcr.io/aojea/kindnet-controller:test aojea/kindnet-controller
docker push aojea/kindnet-controller

- name: Publish image for tags
if: startsWith(github.ref, 'refs/tags/v')
run: |
TAG=$(git describe --tags --abbrev=0)
docker tag ghcr.io/aojea/kindnetd:test aojea/kindnetd:$TAG
docker push aojea/kindnetd:$TAG
docker tag ghcr.io/aojea/kindnet-controller:test aojea/kindnet-controller:$TAG
docker push aojea/kindnet-controller:$TAG

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
Expand All @@ -234,17 +260,32 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
- name: Extract metadata (tags, labels) for Docker kindnetd
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: ${{ env.REGISTRY }}/aojea/kindnetd

- name: Build and push Docker image
- name: Build and push Docker image kindnetd
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
file: Dockerfile.kindnetd
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Extract metadata (tags, labels) for Docker kindnet-controller
id: meta2
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/aojea/kindnet-controller

- name: Build and push Docker image kindnet-controller
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
file: Dockerfile.kindnet-controller
push: true
tags: ${{ steps.meta2.outputs.tags }}
labels: ${{ steps.meta2.outputs.labels }}
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
- uses: actions/checkout@v3
- run: make test
- run: make lint

- run: make verify
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
#
*.swp
.gopath~/
bin/
vendor/src
19 changes: 19 additions & 0 deletions Dockerfile.kindnet-controller
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ARG GOARCH="amd64"
# STEP 1: Build kindnet-controller binary
FROM golang:1.22 AS builder
# golang envs
ARG GOARCH="amd64"
ARG GOOS=linux
ENV CGO_ENABLED=0
ENV GO111MODULE="on"
ENV GOPROXY=https://proxy.golang.org
# copy in sources
WORKDIR /src
COPY . .
# build
RUN CGO_ENABLED=0 go build -o /go/bin/kindnet-controller ./cmd/kindnet-controller
# STEP 2: Build small image
FROM gcr.io/distroless/static-debian12
LABEL org.opencontainers.image.source=https://github.com/aojea/kindnet
COPY --from=builder --chown=root:root /go/bin/kindnet-controller /bin/kindnet-controller
CMD ["/bin/kindnet-controller"]
1 change: 1 addition & 0 deletions Dockerfile → Dockerfile.kindnetd
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ RUN echo "Installing CNI binaries ..." \
-delete
# STEP 2: Build small image
FROM registry.k8s.io/build-image/distroless-iptables:v0.5.2
LABEL org.opencontainers.image.source=https://github.com/aojea/kindnet
COPY --from=builder --chown=root:root /go/bin/kindnetd /bin/kindnetd
COPY --from=builder --chown=root:root /opt/cni/bin /opt/cni/bin
CMD ["/bin/kindnetd"]
29 changes: 15 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@ test:
lint:
hack/lint.sh

update:
update: update-vendor generate

verify:
hack/verify-all.sh

# Generate code
generate:
hack/update-codegen.sh

update-vendor:
go mod tidy && go mod vendor

# get image name from directory we're building
IMAGE_NAME=kindnetd
# docker image registry, default to upstream
REGISTRY?=ghcr.io/aojea
# tag based on date-sha
TAG?=$(shell echo "$$(date +v%Y%m%d)-$$(git describe --always --dirty)")
# the full image tag
IMAGE?=$(REGISTRY)/$(IMAGE_NAME):$(TAG)

# required to enable buildx
export DOCKER_CLI_EXPERIMENTAL=enabled
image-build:
# docker buildx build --platform=${PLATFORMS} $(OUTPUT) --progress=$(PROGRESS) -t ${IMAGE} --pull $(EXTRA_BUILD_OPT) .
docker build . -t ${IMAGE}
hack/build-images.sh




120 changes: 120 additions & 0 deletions apis/generated/clientset/versioned/clientset.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading