Skip to content

Commit

Permalink
Update to k8s 1.25, update deps, add docker-image ghcr
Browse files Browse the repository at this point in the history
  • Loading branch information
martin31821 authored and Jasper-Ben committed Jul 20, 2023
1 parent 61d3d09 commit 70bb357
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 122 deletions.
71 changes: 0 additions & 71 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/deploy.yaml

This file was deleted.

57 changes: 57 additions & 0 deletions .github/workflows/docker-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build Docker Images

on:
push:
tags:
- '**'
branches:
- 'main'
pull_request:
types:
- "opened"
- "reopened"
- "synchronize"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
strategy:
matrix:
image: ["eks-rolling-update"]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.image }}
tags: |
type=semver,pattern={{version}}
type=edge
type=ref,event=pr
- name: Build and push Docker Images
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
build-args: |
"TARGET=${{ matrix.image }}"
"VERSION=${{ version }}"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
venv
.venv
.DS_Store
*.pyc
.vscode
Expand All @@ -8,4 +9,4 @@ venv
.eggs/
build/
dist/
*.egg-info/
*.egg-info/
15 changes: 7 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
FROM python:3-alpine3.10 as builder
ARG VERSION
FROM python:3.11.4-alpine3.18 as builder
ARG KUBERNETES_VERSION=v1.25.10
ARG VERSION=master
RUN apk add --no-cache curl make && \
curl -LO https://amazon-eks.s3-us-west-2.amazonaws.com/1.14.6/2019-08-22/bin/linux/amd64/aws-iam-authenticator && \
chmod +x aws-iam-authenticator && \
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && \
curl -LO https://storage.googleapis.com/kubernetes-release/release/${KUBERNETES_VERSION}/bin/linux/amd64/kubectl && \
chmod +x kubectl

COPY . .
RUN make dist version=${VERSION}

FROM python:3-alpine3.10
FROM python:3.11.4-alpine3.18

COPY --from=builder /aws-iam-authenticator /kubectl /usr/local/bin/
COPY --from=builder /kubectl /usr/local/bin/
COPY --from=builder /dist/*.whl /tmp

RUN apk add --no-cache bash gcc musl-dev
RUN pip3 install --no-cache-dir \
awscli \
/tmp/*.whl && \
rm -rf /tmp/* && \
AWS_DEFAULT_REGION=us-east-1 eks_rolling_update.py -h
AWS_DEFAULT_REGION=eu-central-1 eks_rolling_update.py -h

WORKDIR /app
ENTRYPOINT ["eks_rolling_update.py"]
2 changes: 1 addition & 1 deletion eksrollup/lib/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def is_asg_scaled(asg_name, desired_capacity):
)
actual_instances = response['AutoScalingGroups'][0]['Instances']
if len(actual_instances) != desired_capacity:
logger.info('Asg {} does not have enough running instances to proceed'.format(asg_name))
logger.info('Asg {} does not have the correct number of running instances to proceed'.format(asg_name))
logger.info('Actual instances: {} Desired instances: {}'.format(
len(actual_instances),
desired_capacity)
Expand Down
2 changes: 1 addition & 1 deletion eksrollup/lib/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def drain_node(node_name):
kubectl_args = [
'kubectl', 'drain', node_name,
'--ignore-daemonsets',
'--delete-local-data'
'--delete-emptydir-data'
]
kubectl_args += app_config['EXTRA_DRAIN_ARGS']

Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
boto3~=1.9.246
kubernetes~=10.0.1
boto3~=1.26.153
kubernetes~=25.3.0
python-dotenv~=0.10.2
urllib3<1.26
urllib3<1.26

0 comments on commit 70bb357

Please sign in to comment.