Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #14 from OctopusDeployLabs/new-k8s-repo
Browse files Browse the repository at this point in the history
Update kubernetes apt repo for ubuntu builds
  • Loading branch information
harrisonmeister authored Jan 25, 2024
2 parents 3f5e224 + 08c6546 commit 4382e0a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/docker-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
outputs:
VERSION: ${{ steps.step1.outputs.VERSION }}
GCLOUD_CLI_VERSION: ${{ steps.step1.outputs.GCLOUD_CLI_VERSION }}
KUBECTL_MAJOR_MINOR_VERSION: ${{ steps.step1.outputs.KUBECTL_MAJOR_MINOR_VERSION }}
CONTINUE: ${{ steps.step1.outputs.Continue }}
WIN2019_VERSION: ${{ steps.step1.outputs.WIN2019_VERSION }}
WIN2022_VERSION: ${{ steps.step1.outputs.WIN2022_VERSION }}
Expand Down Expand Up @@ -73,11 +74,16 @@ jobs:
else {
$versionToCompare = "$($version.Major).$($version.Minor).$($version.Build)"
Write-Host "Parsed version as $versionToCompare"
# Major/minor version is used for linux dockerfile to install kubectl correctly
$majorMinorVersion = "$($version.Major).$($version.Minor)"
Write-Host "kubectl Major.Minor: $majorMinorVersion"
$workerToolsTags = Invoke-RestMethod "https://registry.hub.docker.com/v2/repositories/octopuslabs/k8s-workertools/tags?page_size=50"
$matchingTag = $workerToolsTags.results | Where-Object { $_.name -eq $versionToCompare }
echo "VERSION=$versionToCompare" >> $env:GITHUB_OUTPUT
echo "KUBECTL_MAJOR_MINOR_VERSION=$majorMinorVersion" >> $env:GITHUB_OUTPUT
if ($null -ne $matchingTag)
{
Expand Down Expand Up @@ -126,8 +132,9 @@ jobs:

- name: Build the ubuntu.2004 image
env:
VERSION_NUMBER: ${{ needs.get-version-number.outputs.VERSION }}
run: docker build ./ubuntu-2004 --tag octopuslabs/k8s-workertools:$VERSION_NUMBER-ubuntu.2004 --tag octopuslabs/k8s-workertools:latest-ubuntu.2004
VERSION_NUMBER: ${{ needs.get-version-number.outputs.VERSION }}
KUBECTL_MAJOR_MINOR_VERSION: ${{ needs.get-version-number.outputs.KUBECTL_MAJOR_MINOR_VERSION }}
run: docker build ./ubuntu-2004 --build-arg KUBECTL_MAJOR_MINOR_VERSION=$KUBECTL_MAJOR_MINOR_VERSION --tag octopuslabs/k8s-workertools:$VERSION_NUMBER-ubuntu.2004 --tag octopuslabs/k8s-workertools:latest-ubuntu.2004
if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }}

- name: Push the ubuntu.2004 version-specific image
Expand All @@ -142,8 +149,9 @@ jobs:

- name: Build the ubuntu.2204 image
env:
VERSION_NUMBER: ${{ needs.get-version-number.outputs.VERSION }}
run: docker build ./ubuntu-2204 --tag octopuslabs/k8s-workertools:$VERSION_NUMBER-ubuntu.2204 --tag octopuslabs/k8s-workertools:latest-ubuntu.2204
VERSION_NUMBER: ${{ needs.get-version-number.outputs.VERSION }}
KUBECTL_MAJOR_MINOR_VERSION: ${{ needs.get-version-number.outputs.KUBECTL_MAJOR_MINOR_VERSION }}
run: docker build ./ubuntu-2204 --build-arg KUBECTL_MAJOR_MINOR_VERSION=$KUBECTL_MAJOR_MINOR_VERSION --tag octopuslabs/k8s-workertools:$VERSION_NUMBER-ubuntu.2204 --tag octopuslabs/k8s-workertools:latest-ubuntu.2204
if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }}

- name: Push the ubuntu.2204 version-specific image
Expand Down
6 changes: 4 additions & 2 deletions ubuntu-2004/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
FROM octopuslabs/workertools:latest-ubuntu.2004

ARG DEBIAN_FRONTEND noninteractive
ARG KUBECTL_MAJOR_MINOR_VERSION=1.29

# Get kubectl
# https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#install-using-native-package-management
RUN curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/kubernetes-archive-keyring.gpg && \
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | tee /etc/apt/sources.list.d/kubernetes.list && \
RUN mkdir -m 755 /etc/apt/keyrings && \
curl -fsSL "https://pkgs.k8s.io/core:/stable:/v${KUBECTL_MAJOR_MINOR_VERSION}/deb/Release.key" | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v${KUBECTL_MAJOR_MINOR_VERSION}/deb/ /" | tee /etc/apt/sources.list.d/kubernetes.list && \
apt-get update && apt-get install -y kubectl

# Install git
Expand Down
5 changes: 3 additions & 2 deletions ubuntu-2204/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM octopuslabs/workertools:latest-ubuntu.2204

ARG DEBIAN_FRONTEND noninteractive
ARG KUBECTL_MAJOR_MINOR_VERSION=1.29

# Get kubectl
# https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#install-using-native-package-management
RUN curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/kubernetes-archive-keyring.gpg && \
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | tee /etc/apt/sources.list.d/kubernetes.list && \
RUN curl -fsSL "https://pkgs.k8s.io/core:/stable:/v${KUBECTL_MAJOR_MINOR_VERSION}/deb/Release.key" | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v${KUBECTL_MAJOR_MINOR_VERSION}/deb/ /" | tee /etc/apt/sources.list.d/kubernetes.list && \
apt-get update && apt-get install -y kubectl

# Install git
Expand Down

0 comments on commit 4382e0a

Please sign in to comment.