Skip to content

Commit af6aaa4

Browse files
committed
feat: untangle specific cluster build needs from ci here
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
1 parent 9b6b237 commit af6aaa4

8 files changed

Lines changed: 134 additions & 57 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Docker Build and Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
pull_request: {}
8+
9+
env:
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: converged-computing/usernetes
12+
13+
jobs:
14+
build-and-push:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
27+
- name: Log in to the Container registry
28+
if: github.event_name != 'pull_request'
29+
uses: docker/login-action@v3
30+
with:
31+
registry: ${{ env.REGISTRY }}
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Extract metadata (tags, labels)
36+
id: meta
37+
uses: docker/metadata-action@v5
38+
with:
39+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
40+
file: Dockerfile.d/Dockerfile.base
41+
tags: |
42+
# Set node-base as the primary tag for the main branch
43+
type=raw,value=node-base,enable=${{ github.ref == 'refs/heads/main' }}
44+
# Add SHA tag for traceability
45+
type=sha,format=short
46+
# Tag PRs with the PR number
47+
type=ref,event=pr
48+
49+
- name: Build and push Docker image
50+
uses: docker/build-push-action@v5
51+
with:
52+
file: Dockerfile.d/Dockerfile.base
53+
context: .
54+
# Only push if it's NOT a pull request
55+
push: ${{ github.event_name != 'pull_request' }}
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
# Use GitHub Actions cache to speed up builds
59+
cache-from: type=gha
60+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,7 @@
1-
ARG BASE_IMAGE=docker.io/kindest/node:v1.33.0@sha256:91e9ed777db80279c22d1d1068c091b899b2078506e4a0f797fbf6e397c0b0b2
2-
ARG CNI_PLUGINS_VERSION=v1.7.1
3-
ARG HELM_VERSION=v3.17.3
4-
ARG FLANNEL_VERSION=v0.26.7
1+
ARG BASE_IMAGE=ghcr.io/converged-computing/usernetes:node-base
2+
# Edit this image to add / adopt for your environment
53
FROM ${BASE_IMAGE}
6-
COPY Dockerfile.d/SHA256SUMS.d/ /tmp/SHA256SUMS.d
7-
ARG CNI_PLUGINS_VERSION
8-
ARG HELM_VERSION
9-
ARG FLANNEL_VERSION
104
# This are private on our cluster and need to be copied to here
115
COPY cspca.llnl.gov.cer.pem /usr/local/share/ca-certificates/
126
COPY cspca.cer.pem /usr/local/share/ca-certificates/
137
RUN update-ca-certificates
14-
RUN arch="$(uname -m | sed -e s/x86_64/amd64/ -e s/aarch64/arm64/)" && \
15-
fname="cni-plugins-linux-${arch}-${CNI_PLUGINS_VERSION}.tgz" && \
16-
curl --insecure -o "${fname}" -fSL "https://github.com/containernetworking/plugins/releases/download/${CNI_PLUGINS_VERSION}/${fname}" && \
17-
grep "${fname}" "/tmp/SHA256SUMS.d/cni-plugins-${CNI_PLUGINS_VERSION}" | sha256sum -c && \
18-
mkdir -p /opt/cni/bin && \
19-
tar xzf "${fname}" -C /opt/cni/bin && \
20-
rm -f "${fname}" && \
21-
fname="helm-${HELM_VERSION}-linux-${arch}.tar.gz" && \
22-
curl --insecure -o "${fname}" -fSL "https://get.helm.sh/${fname}" && \
23-
grep "${fname}" "/tmp/SHA256SUMS.d/helm-${HELM_VERSION}" | sha256sum -c && \
24-
tar xzf "${fname}" -C /usr/local/bin --strip-components=1 -- "linux-${arch}/helm" && \
25-
rm -f "${fname}" && \
26-
fname="flannel.tgz" && \
27-
curl --insecure -o "${fname}" -fSL "https://github.com/flannel-io/flannel/releases/download/${FLANNEL_VERSION}/${fname}" && \
28-
grep "${fname}" "/tmp/SHA256SUMS.d/flannel-${FLANNEL_VERSION}" | sha256sum -c && \
29-
tar xzf "${fname}" -C / && \
30-
rm -f "${fname}"
31-
# gettext-base: for `envsubst`
32-
# moreutils: for `sponge`
33-
# socat: for `socat` (to silence "[WARNING FileExisting-socat]" from kubeadm)
34-
RUN apt-get update && apt-get install -y --no-install-recommends \
35-
gettext-base \
36-
moreutils \
37-
socat
38-
ADD Dockerfile.d/etc_udev_rules.d_90-flannel.rules /etc/udev/rules.d/90-flannel.rules
39-
ADD Dockerfile.d/u7s-entrypoint.sh /
40-
ENTRYPOINT ["/u7s-entrypoint.sh", "/usr/local/bin/entrypoint", "/sbin/init"]

Dockerfile.d/Dockerfile.base

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
ARG BASE_IMAGE=docker.io/kindest/node:v1.33.0@sha256:91e9ed777db80279c22d1d1068c091b899b2078506e4a0f797fbf6e397c0b0b2
2+
ARG CNI_PLUGINS_VERSION=v1.7.1
3+
ARG HELM_VERSION=v3.17.3
4+
ARG FLANNEL_VERSION=v0.26.7
5+
FROM ${BASE_IMAGE}
6+
COPY Dockerfile.d/SHA256SUMS.d/ /tmp/SHA256SUMS.d
7+
ARG CNI_PLUGINS_VERSION
8+
ARG HELM_VERSION
9+
ARG FLANNEL_VERSION
10+
RUN arch="$(uname -m | sed -e s/x86_64/amd64/ -e s/aarch64/arm64/)" && \
11+
fname="cni-plugins-linux-${arch}-${CNI_PLUGINS_VERSION}.tgz" && \
12+
curl --insecure -o "${fname}" -fSL "https://github.com/containernetworking/plugins/releases/download/${CNI_PLUGINS_VERSION}/${fname}" && \
13+
grep "${fname}" "/tmp/SHA256SUMS.d/cni-plugins-${CNI_PLUGINS_VERSION}" | sha256sum -c && \
14+
mkdir -p /opt/cni/bin && \
15+
tar xzf "${fname}" -C /opt/cni/bin && \
16+
rm -f "${fname}" && \
17+
fname="helm-${HELM_VERSION}-linux-${arch}.tar.gz" && \
18+
curl --insecure -o "${fname}" -fSL "https://get.helm.sh/${fname}" && \
19+
grep "${fname}" "/tmp/SHA256SUMS.d/helm-${HELM_VERSION}" | sha256sum -c && \
20+
tar xzf "${fname}" -C /usr/local/bin --strip-components=1 -- "linux-${arch}/helm" && \
21+
rm -f "${fname}" && \
22+
fname="flannel.tgz" && \
23+
curl --insecure -o "${fname}" -fSL "https://github.com/flannel-io/flannel/releases/download/${FLANNEL_VERSION}/${fname}" && \
24+
grep "${fname}" "/tmp/SHA256SUMS.d/flannel-${FLANNEL_VERSION}" | sha256sum -c && \
25+
tar xzf "${fname}" -C / && \
26+
rm -f "${fname}"
27+
# gettext-base: for `envsubst`
28+
# moreutils: for `sponge`
29+
# socat: for `socat` (to silence "[WARNING FileExisting-socat]" from kubeadm)
30+
RUN apt-get update && apt-get install -y --no-install-recommends \
31+
gettext-base \
32+
moreutils \
33+
socat ipset wget
34+
ADD Dockerfile.d/etc_udev_rules.d_90-flannel.rules /etc/udev/rules.d/90-flannel.rules
35+
ADD Dockerfile.d/u7s-entrypoint.sh /
36+
ENTRYPOINT ["/u7s-entrypoint.sh", "/usr/local/bin/entrypoint", "/sbin/init"]

docker-compose.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
---
44
services:
55
node:
6-
image: usernetes_node
6+
build:
7+
context: .
8+
dockerfile: Dockerfile.d/Dockerfile.base
79
hostname: ${NODE_NAME}
810
privileged: true
911
restart: always

hack/create-cluster-lima.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ done
4646
${LIMACTL} shell host0 ${SERVICE_PORTS} CONTAINER_ENGINE="${CONTAINER_ENGINE}" make -C "${guest_home}/usernetes" kubeadm-init install-flannel kubeconfig join-command
4747

4848
# Let host1 join the cluster
49-
${LIMACTL} copy host0:~/usernetes/join-command host1:~/usernetes/join-command
49+
# ${LIMACTL} copy host0:~/usernetes/join-command host1:~/usernetes/join-command
50+
${LIMACTL} copy host0:~/usernetes/join-command ./join-command
51+
${LIMACTL} copy ./join-command host1:~/usernetes/join-command
5052
${LIMACTL} shell host1 ${SERVICE_PORTS} CONTAINER_ENGINE="${CONTAINER_ENGINE}" make -C "${guest_home}/usernetes" kubeadm-join
5153
${LIMACTL} shell host0 ${SERVICE_PORTS} CONTAINER_ENGINE="${CONTAINER_ENGINE}" make -C "${guest_home}/usernetes" sync-external-ip
5254

hack/test-smoke.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ EOF
5454
INFO "Waiting for 3 replicas to be ready"
5555
kubectl rollout status --timeout=5m statefulset
5656

57+
INFO "GET PODS"
58+
kubectl get pods
59+
INFO "DESCRIBE PODS"
60+
kubectl describe pods
61+
for name in $(kubectl get pods -o json | jq -r .items[].metadata.name)
62+
do
63+
kubectl logs $name
64+
done
65+
5766
INFO "Connecting to dnstest-{0,1,2}.dnstest.default.svc.cluster.local"
5867
kubectl run -i --rm --image=alpine --restart=Never dnstest-shell -- sh -exc 'for f in $(seq 0 2); do wget -O- http://dnstest-${f}.dnstest.default.svc.cluster.local; done'
5968

service/usernetes-start-control-plane.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ USERNETES_TEMPLATE_PATH=/usr/workspace/usernetes/usernetes-06-26-2025
1010
# We will copy join command here
1111
shared_join_command_dir="/usr/workspace/usernetes"
1212

13+
# Logging functions for consistency (like Akihiro!)
14+
log() {
15+
echo "$(date '+%Y-%m-%d %H:%M:%S') - INFO - $1"
16+
}
17+
18+
error_exit() {
19+
echo "$(date '+%Y-%m-%d %H:%M:%S') - ERROR - $1" >&2
20+
exit 1
21+
}
22+
1323
# The user needs to run the setup script
1424
USERNAME=$(whoami)
1525

@@ -37,16 +47,6 @@ which podman-compose
3747
# We don't want to use /var because that is a memory based fs
3848
export TMPDIR="/tmp/${USERNAME}"
3949

40-
# Logging functions for consistency (like Akihiro!)
41-
log() {
42-
echo "$(date '+%Y-%m-%d %H:%M:%S') - INFO - $1"
43-
}
44-
45-
error_exit() {
46-
echo "$(date '+%Y-%m-%d %H:%M:%S') - ERROR - $1" >&2
47-
exit 1
48-
}
49-
5050
install_kubectl() {
5151
if ! command -v kubectl > /dev/null; then
5252
log "Installing kubectl..."

service/usernetes-start-worker.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ set -euo pipefail
77
USERNETES_CONTAINER_TECH=${1:-"podman"}
88
USERNETES_TEMPLATE_PATH=/usr/workspace/usernetes/usernetes-06-26-2025
99

10+
# Logging functions for consistency (like Akihiro!)
11+
log() {
12+
echo "$(date '+%Y-%m-%d %H:%M:%S') - INFO - $1"
13+
}
14+
15+
error_exit() {
16+
echo "$(date '+%Y-%m-%d %H:%M:%S') - ERROR - $1" >&2
17+
exit 1
18+
}
19+
20+
1021
# The join command needs to be here
1122
shared_join_command_dir="/usr/workspace/usernetes"
1223
if [ ! -f "${shared_join_command_dir}/join-command" ]
@@ -38,16 +49,6 @@ log " Updated PATH: ${PATH}"
3849
# We don't want to use /var because that is a memory based fs
3950
export TMPDIR="/tmp/${USERNAME}"
4051

41-
# Logging functions for consistency (like Akihiro!)
42-
log() {
43-
echo "$(date '+%Y-%m-%d %H:%M:%S') - INFO - $1"
44-
}
45-
46-
error_exit() {
47-
echo "$(date '+%Y-%m-%d %H:%M:%S') - ERROR - $1" >&2
48-
exit 1
49-
}
50-
5152
install_kubectl() {
5253
if ! command -v kubectl > /dev/null; then
5354
log "Installing kubectl..."

0 commit comments

Comments
 (0)