Skip to content

Commit

Permalink
Reorganize repo
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Sep 12, 2024
1 parent eaa3b3d commit cc5d722
Show file tree
Hide file tree
Showing 23 changed files with 296 additions and 150 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ jobs:
build:
name: Build
runs-on: ubuntu-24.04
strategy:
matrix:
provider: [capa, capg, caph, capz]
steps:
- uses: actions/checkout@v1

- name: Print version info
id: semver
run: |
make version
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
Expand All @@ -40,8 +38,10 @@ jobs:

- name: Run checks
run: |
cd ${{ matrix.provider }}
make ci
- name: Build
run: |
cd ${{ matrix.provider }}
make release
10 changes: 0 additions & 10 deletions Dockerfile

This file was deleted.

4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# capi-scripts

* `make release`
# capi-deployer
19 changes: 19 additions & 0 deletions capa/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM alpine AS builder

LABEL org.opencontainers.image.source=https://github.com/kluster-api/capi-deployer

ARG TARGETOS
ARG TARGETARCH

ARG CLUSTERCTL="v1.6.3"
ARG CLUSTERAWSADM_VERSION="v2.4.2"
ARG INFRASTRUCTURE_VERSION="v2.4.2"
ARG CLUSTER_API_VERSION="v1.6.3"
ARG IAM_AUTHENTICATOR_VERSION="0.6.14"

RUN apk add --update --no-cache bash ca-certificates curl openssl unzip wget

COPY script.sh .

RUN chmod +x script.sh
RUN ./script.sh
2 changes: 1 addition & 1 deletion Makefile → capa/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SHELL=/bin/bash -o pipefail

REGISTRY ?= ghcr.io/appscode
BIN ?= capi-scripts
BIN ?= $(notdir $(shell pwd))-deployer
IMAGE := $(REGISTRY)/$(BIN)
TAG ?= $(shell git describe --exact-match --abbrev=0 2>/dev/null || echo "")

Expand Down
File renamed without changes.
25 changes: 10 additions & 15 deletions providers/aws/script.sh → capa/script.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#!/bin/bash

HOME="/home/ubuntu"
cd /root
set -xeo pipefail

apt-get -y update

PROVIDER_NAME=aws
SERVICE_NAME=eks-managedmachinepool

Expand Down Expand Up @@ -34,9 +29,11 @@ if [[ "$OSTYPE" == linux* ]]; then
elif [[ "$OSTYPE" == darwin* ]]; then
opsys=darwin
fi

timestamp() {
date +"%Y/%m/%d %T"
}

log() {
local type="$1"
local msg="$2"
Expand All @@ -63,10 +60,6 @@ retry() {
return 0
}

install_wget() {
apt install wget
}

install_nats-logger() {
curl -fsSLO https://github.com/bytebuilders/nats-logger/releases/latest/download/nats-logger-linux-amd64.tar.gz
tar -xzvf nats-logger-linux-amd64.tar.gz
Expand All @@ -87,17 +80,19 @@ install_kubectl() {
ltral="https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/${opsys}/${sys_arch}/kubectl.sha256"
cmnd="curl -LO"
retry 5 ${cmnd} ${ltral}
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
echo "$(cat kubectl.sha256) kubectl" | sha256sum -c
cmnd="install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl"
retry 5 ${cmnd}
}

install_helm() {
local cmnd="curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3"
retry 5 ${cmnd}
chmod 700 get_helm.sh
cmnd="./get_helm.sh"
retry 5 ${cmnd}
}

install_clusterctl() {
local cmnd="curl -L https://github.com/kubernetes-sigs/cluster-api/releases/download/${CLUSTERCTL}/clusterctl-${opsys}-${sys_arch} -o clusterctl"
retry 5 ${cmnd}
Expand All @@ -113,6 +108,7 @@ install_clusterawsadm() {
mv clusterawsadm /usr/local/bin
clusterawsadm version
}

install_aws_iam_authenticator() {
local cmnd="curl -Lo aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v${IAM_AUTHENTICATOR_VERSION}/aws-iam-authenticator_${IAM_AUTHENTICATOR_VERSION}_${opsys}_${sys_arch}"
retry 5 ${cmnd}
Expand Down Expand Up @@ -155,14 +151,13 @@ EOF
}

install_aws_cli() {
apt install unzip >/dev/null
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" >/dev/null
unzip awscliv2.zip >/dev/null
./aws/install >/dev/null
# curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" >/dev/null
# unzip awscliv2.zip >/dev/null
# ./aws/install >/dev/null
apk add --update --no-cache aws-cli
}

init() {
install_wget
install_nats-logger
install_capi-config
install_kubectl
Expand Down
18 changes: 18 additions & 0 deletions capg/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM alpine AS builder

LABEL org.opencontainers.image.source=https://github.com/kluster-api/capi-deployer

ARG TARGETOS
ARG TARGETARCH

ARG CLUSTERCTL="v1.6.3"
ARG INFRASTRUCTURE_VERSION="v1.6.0"
ARG CLUSTER_API_VERSION="v1.6.3"
ARG YQ_VERSION="v4.2.0"

RUN apk add --update --no-cache bash ca-certificates curl openssl unzip wget

COPY script.sh .

RUN chmod +x script.sh
RUN ./script.sh
68 changes: 68 additions & 0 deletions capg/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
SHELL=/bin/bash -o pipefail

REGISTRY ?= ghcr.io/appscode
BIN ?= $(notdir $(shell pwd))-deployer
IMAGE := $(REGISTRY)/$(BIN)
TAG ?= $(shell git describe --exact-match --abbrev=0 2>/dev/null || echo "")

DOCKER_PLATFORMS := linux/amd64 linux/arm64
PLATFORM ?= linux/$(subst x86_64,amd64,$(subst aarch64,arm64,$(shell uname -m)))
VERSION = $(TAG)_$(subst /,_,$(PLATFORM))

container-%:
@$(MAKE) container \
--no-print-directory \
PLATFORM=$(subst _,/,$*)

push-%:
@$(MAKE) push \
--no-print-directory \
PLATFORM=$(subst _,/,$*)

all-container: $(addprefix container-, $(subst /,_,$(DOCKER_PLATFORMS)))

all-push: $(addprefix push-, $(subst /,_,$(DOCKER_PLATFORMS)))

.PHONY: container
container:
@echo "container: $(IMAGE):$(VERSION)"
@docker buildx build --platform $(PLATFORM) --load --pull -t $(IMAGE):$(VERSION) -f Dockerfile .
@echo

push: container
@docker push $(IMAGE):$(VERSION)
@echo "pushed: $(IMAGE):$(VERSION)"
@echo

.PHONY: docker-manifest
docker-manifest:
docker manifest create -a $(IMAGE):$(TAG) $(foreach PLATFORM,$(DOCKER_PLATFORMS),$(IMAGE):$(TAG)_$(subst /,_,$(PLATFORM)))
docker manifest push $(IMAGE):$(TAG)

.PHONY: release
release:
@$(MAKE) all-push docker-manifest --no-print-directory

.PHONY: version
version:
@echo version=$(VERSION)

.PHONY: fmt
fmt:
@find . -path ./vendor -prune -o -name '*.sh' -exec shfmt -l -w -ci -i 4 {} \;

.PHONY: verify
verify: fmt
@if !(git diff --exit-code HEAD); then \
echo "files are out of date, run make fmt"; exit 1; \
fi

.PHONY: ci
ci: verify

# make and load docker image to kind cluster
.PHONY: push-to-kind
push-to-kind: container
@echo "Loading docker image into kind cluster...."
@kind load docker-image $(IMAGE):$(VERSION)
@echo "Image has been pushed successfully into kind cluster."
File renamed without changes.
16 changes: 3 additions & 13 deletions providers/gcp/script.sh → capg/script.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#!/bin/bash

HOME="/home/ubuntu"
cd /root
set -xeo pipefail

apt-get -y update

PROVIDER_NAME=gcp
SERVICE_NAME=gke

Expand Down Expand Up @@ -66,14 +61,10 @@ retry() {
return 0
}

install_wget() {
apt install wget
}

install_yq() {
BINARY="yq_linux_amd64"
wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/${BINARY}.tar.gz -O - |\
tar xz && mv ${BINARY} /bin/yq
wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/${BINARY}.tar.gz -O - |
tar xz && mv ${BINARY} /bin/yq
}

install_nats-logger() {
Expand All @@ -100,7 +91,7 @@ install_kubectl() {
cmnd="curl -LO"
retry 5 ${cmnd} ${ltral}

echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
echo "$(cat kubectl.sha256) kubectl" | sha256sum -c

cmnd="install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl"
retry 5 ${cmnd}
Expand Down Expand Up @@ -162,7 +153,6 @@ EOF
}

init() {
install_wget
install_yq
install_nats-logger
install_capi-config
Expand Down
15 changes: 15 additions & 0 deletions caph/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM alpine AS builder

LABEL org.opencontainers.image.source=https://github.com/kluster-api/capi-deployer

ARG TARGETOS
ARG TARGETARCH

ARG CLUSTERCTL="v1.6.3"

RUN apk add --update --no-cache bash ca-certificates curl openssl unzip wget

COPY script.sh .

RUN chmod +x script.sh
RUN ./script.sh
68 changes: 68 additions & 0 deletions caph/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
SHELL=/bin/bash -o pipefail

REGISTRY ?= ghcr.io/appscode
BIN ?= $(notdir $(shell pwd))-deployer
IMAGE := $(REGISTRY)/$(BIN)
TAG ?= $(shell git describe --exact-match --abbrev=0 2>/dev/null || echo "")

DOCKER_PLATFORMS := linux/amd64 linux/arm64
PLATFORM ?= linux/$(subst x86_64,amd64,$(subst aarch64,arm64,$(shell uname -m)))
VERSION = $(TAG)_$(subst /,_,$(PLATFORM))

container-%:
@$(MAKE) container \
--no-print-directory \
PLATFORM=$(subst _,/,$*)

push-%:
@$(MAKE) push \
--no-print-directory \
PLATFORM=$(subst _,/,$*)

all-container: $(addprefix container-, $(subst /,_,$(DOCKER_PLATFORMS)))

all-push: $(addprefix push-, $(subst /,_,$(DOCKER_PLATFORMS)))

.PHONY: container
container:
@echo "container: $(IMAGE):$(VERSION)"
@docker buildx build --platform $(PLATFORM) --load --pull -t $(IMAGE):$(VERSION) -f Dockerfile .
@echo

push: container
@docker push $(IMAGE):$(VERSION)
@echo "pushed: $(IMAGE):$(VERSION)"
@echo

.PHONY: docker-manifest
docker-manifest:
docker manifest create -a $(IMAGE):$(TAG) $(foreach PLATFORM,$(DOCKER_PLATFORMS),$(IMAGE):$(TAG)_$(subst /,_,$(PLATFORM)))
docker manifest push $(IMAGE):$(TAG)

.PHONY: release
release:
@$(MAKE) all-push docker-manifest --no-print-directory

.PHONY: version
version:
@echo version=$(VERSION)

.PHONY: fmt
fmt:
@find . -path ./vendor -prune -o -name '*.sh' -exec shfmt -l -w -ci -i 4 {} \;

.PHONY: verify
verify: fmt
@if !(git diff --exit-code HEAD); then \
echo "files are out of date, run make fmt"; exit 1; \
fi

.PHONY: ci
ci: verify

# make and load docker image to kind cluster
.PHONY: push-to-kind
push-to-kind: container
@echo "Loading docker image into kind cluster...."
@kind load docker-image $(IMAGE):$(VERSION)
@echo "Image has been pushed successfully into kind cluster."
File renamed without changes.
Loading

0 comments on commit cc5d722

Please sign in to comment.