diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 39bae40..bc52859 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,6 +33,4 @@ jobs: run: make - name: Run e2e tests - run: | - make deploy - kubectl rollout status deploy/kcl-webhook-server --timeout=1m + run: ./scripts/deploy_test.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 5a75cca..8dd4a57 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -23,7 +23,7 @@ jobs: - name: Setup Docker Buildx uses: docker/setup-buildx-action@v3 with: - version: v0.11.2 + version: v0.13.0 install: true - name: Copy and edit amd4 arch for Dockerfile @@ -66,7 +66,7 @@ jobs: - name: Setup Docker Buildx uses: docker/setup-buildx-action@v3 with: - version: v0.11.2 + version: v0.13.0 install: true - name: Copy and edit amd4 arch for Dockerfile @@ -93,99 +93,3 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - - webhook-init-image-arm64: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - - name: Setup QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: all - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - version: v0.11.2 - install: true - - # <--- Login, build and push image to Docker Hub ---> - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Copy and edit arm64 arch for Dockerfile - run: | - cp docker/amd64/Dockerfile.init Dockerfile - sed -i 's/kcllang/kcl-arm64\/kcllang/kcl/g' Dockerfile - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: kcllang/webhook-init-arm64 - - name: Build and push Docker image - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - webhook-server-image-arm64: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - - name: Setup QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: all - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - version: v0.11.2 - install: true - - # <--- Login, build and push image to Docker Hub ---> - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Copy and edit arm64 arch for Dockerfile - run: | - cp docker/amd64/Dockerfile.server Dockerfile - sed -i 's/kcllang/kcl-arm64\/kcllang/kcl/g' Dockerfile - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: kcllang/webhook-server-arm64 - - name: Build and push Docker image - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/README.md b/README.md index 079682a..b6259ea 100644 --- a/README.md +++ b/README.md @@ -103,3 +103,7 @@ See [here](https://kcl-lang.io/docs/reference/lang/tour) to study more features ## Examples See [here](https://github.com/kcl-lang/krm-kcl/tree/main/examples) for more examples. + +git tag v0.1.0 +git push origin v0.1.0 +gh release create v0.1.0 --draft --generate-notes --title "v0.1.0 Release" diff --git a/docker/amd64/Dockerfile.init b/docker/amd64/Dockerfile.init index aac78a5..770c1db 100644 --- a/docker/amd64/Dockerfile.init +++ b/docker/amd64/Dockerfile.init @@ -14,7 +14,7 @@ WORKDIR / COPY . . -RUN GOOS=linux GOARCH=amd64 go build -o webhook-server cmd/wehbook-init +RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o webhook-init cmd/wehbook-init FROM kcllang/kcl diff --git a/docker/amd64/Dockerfile.server b/docker/amd64/Dockerfile.server index ca2f8c8..cb56f98 100644 --- a/docker/amd64/Dockerfile.server +++ b/docker/amd64/Dockerfile.server @@ -14,7 +14,7 @@ WORKDIR / COPY . . -RUN GOOS=linux GOARCH=amd64 go build -o webhook-server cmd/wehbook-server +RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o webhook-server cmd/wehbook-server FROM kcllang/kcl diff --git a/scripts/deploy_test.sh b/scripts/deploy_test.sh new file mode 100755 index 0000000..2c86b15 --- /dev/null +++ b/scripts/deploy_test.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +make deploy +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +NC='\033[0m' + +echo -e "${YELLOW}Monitoring deployment rollout status...${NC}" +kubectl rollout status deploy/kcl-webhook-server --timeout=1m +ROLLOUT_STATUS=$? + +if [ $ROLLOUT_STATUS -ne 0 ]; then + echo -e "${RED}Deployment rollout failed.${NC}" + + echo -e "${YELLOW}Retrieving deployment details...${NC}" + kubectl describe deploy/kcl-webhook-server + + echo -e "${YELLOW}Retrieving ReplicaSet details...${NC}" + RS=$(kubectl get rs -l=app=kcl-webhook-server --output=jsonpath='{.items[*].metadata.name}') + for rs in $RS; do + echo -e "${YELLOW}ReplicaSet: $rs${NC}" + kubectl describe rs/$rs + done + + echo -e "${YELLOW}Retrieving Pod details...${NC}" + PODS=$(kubectl get pods -l=app=kcl-webhook-server --output=jsonpath='{.items[*].metadata.name}') + for pod in $PODS; do + echo -e "${YELLOW}Pod: $pod${NC}" + kubectl describe pod/$pod + echo -e "${YELLOW}Pod logs:${NC}" + kubectl logs $pod + done +else + echo -e "${GREEN}Deployment rollout successful.${NC}" +fi