Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
iLeonidze committed Sep 16, 2021
1 parent 1670acb commit d7fe4ef
Show file tree
Hide file tree
Showing 148 changed files with 39,437 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
documentation
dump
examples
ansible-inventory.ini
cluster.yaml
build.sh
.git
Dockerfile
.DS_Store
.gitignore
*.md
33 changes: 33 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build Artifacts
on:
push:
branches:
- '**'
jobs:
build-image:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Build Docker Image
run: docker build -t kubetool --no-cache .
build-binary:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Build Binary via Docker
run: docker build -t kubetool --build-arg BUILD_TYPE=binary --no-cache .
build-package:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2.2.2
- name: Install Dependencies
run: python3 -m pip install --upgrade pip
- name: Prepare Setuptools
run: python3 -m pip install wheel setuptools build
- name: Build Kubetool Package
run: python3 -m build -n
17 changes: 17 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Publish Artifacts
on:
release:
types: [created]
push:
branches:
- 'main'
env:
TAG_NAME: ${{ github.event.release.tag_name || (github.ref == 'refs/heads/main' && 'main') }}
jobs:
publish-docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: docker build . -t ghcr.io/netcracker-technology/kubetool:${{ env.TAG_NAME }}
- run: echo ${{secrets.GITHUB_TOKEN}} | docker login https://ghcr.io -u ${GITHUB_ACTOR} --password-stdin
- run: docker push ghcr.io/netcracker-technology/kubetool:${{ env.TAG_NAME }}
25 changes: 25 additions & 0 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Unit Tests
on:
push:
branches:
- '**'
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: docker build -t kubetools --build-arg BUILD_TYPE=test --no-cache .
- run: docker run --entrypoint=python3 kubetools -m unittest discover -s /opt/kubetools/test/unit -t /opt/kubetools/test/unit
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: docker build -t kubetools --build-arg BUILD_TYPE=test --no-cache .
- run: docker run --entrypoint=/bin/bash kubetools -c "python3 /usr/local/bin/coverage run -m unittest discover -s /opt/kubetools/test/unit -t /opt/kubetools/test/unit; python3 /usr/local/bin/coverage report -m" > /tmp/report.txt
- run: cat /tmp/report.txt; PERCENTAGE=$(cat /tmp/report.txt | tail -1 | awk '{print $4}' | tr -dc '0-9')
linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: docker build -t kubetools --build-arg BUILD_TYPE=test --no-cache .
- run: docker run --entrypoint=/bin/bash kubetools -c "/usr/local/bin/pylint kubetool test --disable fixme || exit 0"
82 changes: 82 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Project-specific excludes
config
/local_chart_folder
!examples/*
/dump
ansible-inventory.ini
admin.conf
account-tokens.yaml
ca.csr
ca.pem
ca-key.pem
kubernetes.csr
kubernetes.pem
kubernetes-key.pem
/cluster.yaml
/additional.yaml
/procedure.yaml
venv/
build/
dist/
kubecheck
kubecheck.zip
report.*
*.tar
*.tar.gz
*.log

# System & software trash
*~
.idea/
*.iml
*.zip
*.komodoproject
.loadpath
.project
*.pyc
.pydevproject
*.pyo
*.config_oc.yaml
*.redcar*
.*.swp
.sass-cache
.rvmrc
.DS_Store
.vagrant
.tags*
*.retry
.vscode/
.cache
.tox/
.coverage
*.egg-info
.eggs
/Roadmap*
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
*.stackdump
[Dd]esktop.ini
$RECYCLE.BIN/
*.cab
*.msi
*.msix
*.msm
*.msp
*.lnk
.AppleDouble
.LSOverride
Icon
._*
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
Empty file added CONTRIBUTING.md
Empty file.
43 changes: 43 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM python:3.8.12-slim-buster
# Warning! Python and Debian versions should be strict to avoid sudden components upgrade,
# including unreasonable upgrade of GLIBC version. If the GLIBC version suddenly goes up, a large number of consumers
# will suddenly be unable to use the compiled binary version on older systems.

ARG BUILD_TYPE

USER root

ENV ANSIBLE_HOST_KEY_CHECKING False

COPY . /opt/kubetools/
WORKDIR /opt/kubetools/

# The following dependecies required for cryptography package build (see https://github.com/pyca/cryptography/blob/main/docs/installation.rst)
# - build-essential
# - libssl-dev
# - libffi-dev
# - python3-dev
# - cargo
# Finally they should be removed to avoid big size of docker image

RUN apt update && \
apt install -y build-essential libssl-dev libffi-dev python3-dev cargo zlib1g-dev && \
if [ "$BUILD_TYPE" = "binary" ]; then apt install -y upx-ucl binutils; fi && \
pip3 install --upgrade pip && \
pip3 install -r /opt/kubetools/requirements.txt && \
if [ "$BUILD_TYPE" = "test" ]; then pip3 install pytest==5.4.3 pylint coverage; fi && \
if [ "$BUILD_TYPE" = "binary" ]; then pip3 install pyinstaller; fi && \
if [ "$BUILD_TYPE" = "binary" ]; then pyinstaller main.spec --noconfirm && exit 0; fi && \
apt install -y openssl curl && \
curl -k https://get.helm.sh/helm-v3.4.1-linux-amd64.tar.gz -o helm-v3.4.1.tar.gz && \
tar -zxvf helm-v3.4.1.tar.gz && \
mv linux-amd64/helm /usr/local/bin/helm && \
rm -rf helm-v3.4.1.tar.gz && \
rm -rf linux-amd64 && \
apt remove -y build-essential libssl-dev libffi-dev python3-dev cargo && \
apt autoremove -y && \
apt clean -y && \
rm -f /etc/apt/sources.list && \
rm -rf /var/lib/apt/lists/*

ENTRYPOINT ["/opt/kubetools/kubetools"]
19 changes: 19 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

cd "$(dirname "$0")" || exit 1

NAME=${NAME:-kubetools}

if [[ -n "${LOCATION}" ]]; then
sed -i "s|non-release version|version ${LOCATION} build $(date +"%D %T")|g" "kubetool/__main__.py"
fi

rm -rf build.sh documentation examples CONTRIBUTING.md .git

docker build -t "${NAME}" --no-cache .

for id in $DOCKER_NAMES; do
docker tag "${NAME}" "$id"
done

chmod +x kubetools
Loading

0 comments on commit d7fe4ef

Please sign in to comment.