Skip to content

Commit

Permalink
complete rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
jshimko committed Jan 13, 2023
1 parent f2df1c7 commit 3ee441b
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 169 deletions.
59 changes: 0 additions & 59 deletions .circleci/config.yml

This file was deleted.

9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# https://EditorConfig.org

root = true

[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build and Push to Docker Hub

on: [push]

jobs:
docker-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@4
with:
images: jshimko/kube-tools
tags: |
type=ref,event=branch
type=match,pattern=\d+.\d+.\d+
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v3
with:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
temp
83 changes: 40 additions & 43 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,45 +1,42 @@
FROM alpine:3.14

# https://github.com/hypnoglow/helm-s3
ENV HELM_S3_PLUGIN_VERSION "0.10.0"

# set some defaults
ENV AWS_DEFAULT_REGION "us-east-1"

RUN apk --no-cache upgrade
RUN apk add --update bash ca-certificates git python3 jq

# https://github.com/sgerrand/alpine-pkg-glibc/releases
ENV GLIBC_VER=2.33-r0

# install glibc compatibility for alpine and aws-cli v2
# https://github.com/aws/aws-cli/issues/4685#issuecomment-615872019
RUN apk --no-cache add \
binutils \
curl \
&& curl -sL https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub -o /etc/apk/keys/sgerrand.rsa.pub \
&& curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-${GLIBC_VER}.apk \
&& curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-bin-${GLIBC_VER}.apk \
&& apk add --no-cache \
glibc-${GLIBC_VER}.apk \
glibc-bin-${GLIBC_VER}.apk \
&& curl -sL https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zip \
&& unzip awscliv2.zip \
&& aws/install \
&& rm -rf \
awscliv2.zip \
aws \
/usr/local/aws-cli/v2/*/dist/aws_completer \
/usr/local/aws-cli/v2/*/dist/awscli/data/ac.index \
/usr/local/aws-cli/v2/*/dist/awscli/examples \
&& apk --no-cache del \
binutils \
curl \
&& rm glibc-${GLIBC_VER}.apk \
&& rm glibc-bin-${GLIBC_VER}.apk \
&& rm -rf /var/cache/apk/*

COPY install.sh /opt/install.sh
RUN /opt/install.sh
FROM debian:11-slim

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && \
apt upgrade -y && \
apt install -y --no-install-recommends curl git gnupg2 python python3-pip vim wget && \
echo "deb http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
apt -y update && apt install -y --no-install-recommends postgresql-client-14 && \
rm -rf /var/lib/apt/lists/* && \
pip3 install --upgrade pip && \
pip3 install awscli yamllint yq

# kubectl
RUN curl -LO "https://dl.k8s.io/release/$(curl -Ls https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && \
mv kubectl /usr/local/bin/kubectl && \
chmod +x /usr/local/bin/kubectl && \
kubectl version --client

# helm
RUN curl -fsSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash

# helm S3 plugin
RUN helm plugin install https://github.com/hypnoglow/helm-s3.git

# aws-iam-authenticator
# https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html
RUN curl https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v0.5.9/aws-iam-authenticator_0.5.9_linux_amd64 -Lo aws-iam-authenticator && \
chmod +x ./aws-iam-authenticator && \
mv aws-iam-authenticator /usr/local/bin/aws-iam-authenticator && \
aws-iam-authenticator help

# Digital Ocean CLI (doctl)
RUN DOCTL_VERSION=1.92.0 && \
wget https://github.com/digitalocean/doctl/releases/download/v${DOCTL_VERSION}/doctl-${DOCTL_VERSION}-linux-amd64.tar.gz && \
tar xf ./doctl-${DOCTL_VERSION}-linux-amd64.tar.gz && \
mv ./doctl /usr/local/bin && \
rm ./doctl-${DOCTL_VERSION}-linux-amd64.tar.gz && \
doctl help

CMD bash
29 changes: 2 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# kube-tools

A lightweight Docker image (based on Alpine) that comes with all the tools you need to work with Kubernetes, Helm charts, AWS (awscli), AWS EKS, and Digital Ocean Kubernetes. Intended to be a flexible foundation of tools for CI/CD workflows.
A Docker image based on Debian 11 that comes with all the tools you need to work with Kubernetes, Helm charts, AWS (awscli), AWS EKS, and Digital Ocean Kubernetes. Intended to be a flexible foundation of tools for CI/CD workflows.

## Included Tools

Expand All @@ -10,31 +10,6 @@ A lightweight Docker image (based on Alpine) that comes with all the tools you n
- awscli https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html
- aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator
- doctl https://docs.digitalocean.com/reference/doctl/
- psql https://www.postgresql.org/docs/14/app-psql.html
- yamllint - https://github.com/adrienverge/yamllint
- yq (YAML parser based on `jq`) - https://github.com/kislyuk/yq


## Example Usage

```sh
# start up an image
docker run -it \
-e AWS_ACCESS_KEY_ID="<AWS key>" \
-e AWS_SECRET_ACCESS_KEY="<AWS secret>" \
-e AWS_DEFAULT_REGION="us-east-1" \
jshimko/kube-tools-aws:latest

# the above command drops into a bash shell with
# all of the tooling for the following commands...

# configure kubectl auth for an existing EKS cluster named "my-cluster"
aws eks update-kubeconfig --name my-cluster

# confirm it worked by listing your pods
kubectl get pods --all-namespaces

# or list your helm deployments
helm ls --all-namespaces

# now do stuff for your CI/CD process...
```
40 changes: 0 additions & 40 deletions install.sh

This file was deleted.

0 comments on commit 3ee441b

Please sign in to comment.