gitops 0.10.7__tar.gz → 0.11.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gitops-0.11.1/.dockerignore +1 -0
- gitops-0.11.1/.github/workflows/publish.yml +77 -0
- gitops-0.11.1/.github/workflows/test.yml +26 -0
- gitops-0.11.1/.gitignore +14 -0
- gitops-0.11.1/.mise.toml +50 -0
- gitops-0.11.1/.pre-commit-config.yaml +17 -0
- gitops-0.11.1/Dockerfile +53 -0
- gitops-0.11.1/PKG-INFO +90 -0
- gitops-0.11.1/README.md +66 -0
- gitops-0.11.1/charts/gitops/.helmignore +21 -0
- gitops-0.11.1/charts/gitops/Chart.yaml +5 -0
- gitops-0.11.1/charts/gitops/README.md +8 -0
- gitops-0.11.1/charts/gitops/templates/_helpers.tpl +43 -0
- gitops-0.11.1/charts/gitops/templates/certificate.yml +13 -0
- gitops-0.11.1/charts/gitops/templates/deployment.yml +103 -0
- gitops-0.11.1/charts/gitops/templates/environment.yml +8 -0
- gitops-0.11.1/charts/gitops/templates/ingress.yml +29 -0
- gitops-0.11.1/charts/gitops/templates/issuer.yml +16 -0
- gitops-0.11.1/charts/gitops/templates/secrets.yml +14 -0
- gitops-0.11.1/charts/gitops/templates/service.yml +12 -0
- gitops-0.11.1/charts/gitops/templates/serviceaccount.yaml +10 -0
- gitops-0.11.1/charts/gitops/values.yaml +40 -0
- gitops-0.11.1/docker-compose.yml +11 -0
- {gitops-0.10.7 → gitops-0.11.1}/gitops/__init__.py +1 -2
- {gitops-0.10.7 → gitops-0.11.1}/gitops/common/app.py +2 -2
- {gitops-0.10.7 → gitops-0.11.1}/gitops/core.py +1 -1
- {gitops-0.10.7 → gitops-0.11.1}/gitops/db.py +1 -1
- {gitops-0.10.7 → gitops-0.11.1}/gitops/main.py +1 -1
- {gitops-0.10.7 → gitops-0.11.1}/gitops/utils/__init__.py +6 -2
- {gitops-0.10.7 → gitops-0.11.1}/gitops/utils/apps.py +2 -2
- {gitops-0.10.7 → gitops-0.11.1}/gitops/utils/cli.py +1 -0
- {gitops-0.10.7 → gitops-0.11.1}/gitops/utils/images.py +1 -1
- {gitops-0.10.7 → gitops-0.11.1}/gitops/utils/kube.py +10 -10
- {gitops-0.10.7 → gitops-0.11.1}/gitops/utils/yaml.py +4 -4
- gitops-0.11.1/gitops_server/README.md +19 -0
- gitops-0.11.1/gitops_server/__init__.py +0 -0
- gitops-0.11.1/gitops_server/app.py +18 -0
- gitops-0.11.1/gitops_server/main.py +82 -0
- gitops-0.11.1/gitops_server/settings.py +7 -0
- gitops-0.11.1/gitops_server/types.py +34 -0
- gitops-0.11.1/gitops_server/utils/__init__.py +34 -0
- gitops-0.11.1/gitops_server/utils/git.py +37 -0
- gitops-0.11.1/gitops_server/utils/github.py +53 -0
- gitops-0.11.1/gitops_server/utils/slack.py +103 -0
- gitops-0.11.1/gitops_server/workers/__init__.py +2 -0
- gitops-0.11.1/gitops_server/workers/deployer/__init__.py +2 -0
- gitops-0.11.1/gitops_server/workers/deployer/deploy.py +241 -0
- gitops-0.11.1/gitops_server/workers/deployer/hooks.py +92 -0
- gitops-0.11.1/gitops_server/workers/deployer/worker.py +56 -0
- gitops-0.11.1/gitops_server/workers/status_updater/__init__.py +1 -0
- gitops-0.11.1/gitops_server/workers/status_updater/worker.py +126 -0
- gitops-0.11.1/poetry.lock +1808 -0
- gitops-0.11.1/pyproject.toml +62 -0
- gitops-0.11.1/release.py +17 -0
- gitops-0.11.1/ruff.toml +40 -0
- gitops-0.11.1/secrets.example.env +4 -0
- gitops-0.11.1/setup.cfg +23 -0
- gitops-0.11.1/tests/__init__.py +0 -0
- gitops-0.11.1/tests/sample_data.py +377 -0
- gitops-0.11.1/tests/test_app.py +107 -0
- gitops-0.11.1/tests/test_core.py +260 -0
- gitops-0.11.1/tests/test_deploy.py +122 -0
- gitops-0.11.1/tests/test_gitops_server.py +44 -0
- gitops-0.11.1/tests/test_utils.py +171 -0
- gitops-0.11.1/tests/utils.py +87 -0
- gitops-0.11.1/tests/webhook_sample_data.py +225 -0
- gitops-0.11.1/uv.lock +1266 -0
- gitops-0.10.7/PKG-INFO +0 -25
- gitops-0.10.7/gitops/monkeypatches.py +0 -8
- gitops-0.10.7/pyproject.toml +0 -66
- {gitops-0.10.7 → gitops-0.11.1}/LICENSE +0 -0
- {gitops-0.10.7 → gitops-0.11.1}/gitops/common/__init__.py +0 -0
- {gitops-0.10.7 → gitops-0.11.1}/gitops/common/utils.py +0 -0
- {gitops-0.10.7 → gitops-0.11.1}/gitops/py.typed +0 -0
- {gitops-0.10.7 → gitops-0.11.1}/gitops/settings.py +0 -0
- {gitops-0.10.7 → gitops-0.11.1}/gitops/shorthands.py +0 -0
- {gitops-0.10.7 → gitops-0.11.1}/gitops/utils/async_runner.py +0 -0
- {gitops-0.10.7 → gitops-0.11.1}/gitops/utils/exceptions.py +0 -0
- {gitops-0.10.7 → gitops-0.11.1}/gitops/utils/tags.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*.tmp
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
on:
|
|
3
|
+
release:
|
|
4
|
+
types: [published]
|
|
5
|
+
workflow_dispatch: {}
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
actions: read # Read the metrics
|
|
10
|
+
contents: write # to be able to publish a GitHub release
|
|
11
|
+
issues: write # to be able to comment on released issues
|
|
12
|
+
pull-requests: write # to be able to comment on released pull requests
|
|
13
|
+
id-token: write # to enable use of OIDC for npm provenance / AWS
|
|
14
|
+
|
|
15
|
+
env:
|
|
16
|
+
MISE_PYTHON_COMPILE: false
|
|
17
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
push_to_registry:
|
|
21
|
+
name: Push Docker image to Docker Hub
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
steps:
|
|
24
|
+
- name: Configure AWS credentials
|
|
25
|
+
uses: aws-actions/configure-aws-credentials@v2
|
|
26
|
+
with:
|
|
27
|
+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
28
|
+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
29
|
+
aws-region: ap-southeast-2
|
|
30
|
+
|
|
31
|
+
- name: Docker Login to Amazon ECR
|
|
32
|
+
id: login-ecr
|
|
33
|
+
uses: aws-actions/amazon-ecr-login@v1
|
|
34
|
+
|
|
35
|
+
- name: Check out the repo
|
|
36
|
+
uses: actions/checkout@v3
|
|
37
|
+
|
|
38
|
+
- name: Pull latest image. Build docker image and publish it.
|
|
39
|
+
env:
|
|
40
|
+
latest_image: 305686791668.dkr.ecr.ap-southeast-2.amazonaws.com/gitops:latest
|
|
41
|
+
current_image: 305686791668.dkr.ecr.ap-southeast-2.amazonaws.com/gitops:${{github.event.release.tag_name}}
|
|
42
|
+
run: |
|
|
43
|
+
echo ${{secrets.CLUSTER_KEY}} | base64 -d > cluster.key
|
|
44
|
+
docker pull $latest_image
|
|
45
|
+
docker build -t $latest_image --cache-from $latest_image .
|
|
46
|
+
docker push $latest_image
|
|
47
|
+
docker tag $latest_image $current_image
|
|
48
|
+
docker push $current_image
|
|
49
|
+
echo "Published image at: $current_image"
|
|
50
|
+
|
|
51
|
+
publish_helm_chart:
|
|
52
|
+
runs-on: ubuntu-latest
|
|
53
|
+
steps:
|
|
54
|
+
- uses: actions/checkout@v3
|
|
55
|
+
- name: Publish Helm charts
|
|
56
|
+
uses: stefanprodan/helm-gh-pages@master
|
|
57
|
+
with:
|
|
58
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
59
|
+
|
|
60
|
+
publish_to_pypi:
|
|
61
|
+
name: Publishes tag to pypi
|
|
62
|
+
runs-on: ubuntu-latest
|
|
63
|
+
steps:
|
|
64
|
+
- uses: actions/checkout@v3
|
|
65
|
+
|
|
66
|
+
- uses: jdx/mise-action@v2
|
|
67
|
+
with:
|
|
68
|
+
install: true
|
|
69
|
+
cache: true
|
|
70
|
+
experimental: true
|
|
71
|
+
|
|
72
|
+
- run: |
|
|
73
|
+
mise run build
|
|
74
|
+
shell: bash
|
|
75
|
+
|
|
76
|
+
- name: Publish Pypi Package
|
|
77
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- develop
|
|
6
|
+
pull_request: ~
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
actions: read # Read the metrics
|
|
10
|
+
contents: write # to be able to publish a GitHub release
|
|
11
|
+
issues: write # to be able to comment on released issues
|
|
12
|
+
pull-requests: write # to be able to comment on released pull requests
|
|
13
|
+
id-token: write # to enable use of OIDC for npm provenance / AWS
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
ci:
|
|
17
|
+
uses: uptick/actions/.github/workflows/ci.yaml@main
|
|
18
|
+
secrets: inherit
|
|
19
|
+
with:
|
|
20
|
+
praise-on-fix: false
|
|
21
|
+
python-version: 3.12
|
|
22
|
+
mise: true
|
|
23
|
+
mise-install: true
|
|
24
|
+
command: |
|
|
25
|
+
mise run install
|
|
26
|
+
mise run ci
|
gitops-0.11.1/.gitignore
ADDED
gitops-0.11.1/.mise.toml
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[tools]
|
|
2
|
+
python = { version = "3.12.1", venv = ".venv" }
|
|
3
|
+
uv = { version = "0.4.7"}
|
|
4
|
+
|
|
5
|
+
[env]
|
|
6
|
+
_.python.venv = { path = "{{config_root}}/.venv", create = true }
|
|
7
|
+
|
|
8
|
+
[tasks.start]
|
|
9
|
+
run = "uvicorn --host 0.0.0.0 --port 8000 gitops_server.main:app --reload"
|
|
10
|
+
|
|
11
|
+
[tasks."install"]
|
|
12
|
+
run = ["uv sync --all-extras"]
|
|
13
|
+
|
|
14
|
+
[tasks."lint"]
|
|
15
|
+
run = ["uv run ruff check ."]
|
|
16
|
+
|
|
17
|
+
[tasks."format"]
|
|
18
|
+
run = ["uv run ruff format ."]
|
|
19
|
+
|
|
20
|
+
[tasks."test"]
|
|
21
|
+
run = ["uv run py.test"]
|
|
22
|
+
|
|
23
|
+
[tasks."mypy"]
|
|
24
|
+
run = ["uv run mypy ."]
|
|
25
|
+
|
|
26
|
+
[tasks."ci"]
|
|
27
|
+
depends = ["lint", "format", "test", "mypy"]
|
|
28
|
+
|
|
29
|
+
[tasks."helm:lint"]
|
|
30
|
+
run = "helm install --dry-run --debug -f charts/gitops/values.yaml debug charts/gitops"
|
|
31
|
+
|
|
32
|
+
[tasks.release]
|
|
33
|
+
description = "Bump release versions across all files"
|
|
34
|
+
run = "python release.py"
|
|
35
|
+
|
|
36
|
+
[tasks.start_otel]
|
|
37
|
+
run = ["""
|
|
38
|
+
OTEL_PYTHON_LOG_CORRELATION=true \
|
|
39
|
+
OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=True \
|
|
40
|
+
OTEL_LOGS_EXPORTER=none \
|
|
41
|
+
OTEL_METRICS_EXPORTER=none \
|
|
42
|
+
OTEL_TRACES_EXPORTER=console \
|
|
43
|
+
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 \
|
|
44
|
+
OTEL_RESOURCE_ATTRIBUTES=server_name=gitops \
|
|
45
|
+
OTEL_SERVICE_NAME=gitops-test \
|
|
46
|
+
OTEL_EXPORTER_OTLP_TIMEOUT=1 \
|
|
47
|
+
uvicorn --host 0.0.0.0 --port 7000 gitops_server.main:app"""]
|
|
48
|
+
|
|
49
|
+
[tasks.build]
|
|
50
|
+
run = "uv build"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
|
3
|
+
rev: v0.6.3
|
|
4
|
+
hooks:
|
|
5
|
+
- id: ruff
|
|
6
|
+
args:
|
|
7
|
+
- --fix
|
|
8
|
+
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
|
9
|
+
rev: v0.6.3
|
|
10
|
+
hooks:
|
|
11
|
+
- id: ruff-format
|
|
12
|
+
- repo: https://github.com/commitizen-tools/commitizen
|
|
13
|
+
rev: v3.14.1
|
|
14
|
+
hooks:
|
|
15
|
+
- id: commitizen
|
|
16
|
+
stages:
|
|
17
|
+
- commit-msg
|
gitops-0.11.1/Dockerfile
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
FROM python:3.12-slim
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
## Install kubectl and dependencies.
|
|
5
|
+
##
|
|
6
|
+
# RUN apk add -U openssl curl tar gzip bash ca-certificates && \
|
|
7
|
+
# wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub && \
|
|
8
|
+
# wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.23-r3/glibc-2.23-r3.apk && \
|
|
9
|
+
# apk add glibc-2.23-r3.apk && \
|
|
10
|
+
# rm glibc-2.23-r3.apk
|
|
11
|
+
# RUN curl -L -o /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.8.0/bin/linux/amd64/kubectl && \
|
|
12
|
+
# chmod +x /usr/bin/kubectl && \
|
|
13
|
+
# kubectl version --client
|
|
14
|
+
ENV KUBE_LATEST_VERSION="v1.21.3"
|
|
15
|
+
ENV HELM_VERSION="v3.6.2" \
|
|
16
|
+
VIRTUAL_ENV="/app/.venv" \
|
|
17
|
+
PATH="/app/.venv/bin:$PATH"
|
|
18
|
+
RUN apt-get update
|
|
19
|
+
RUN apt-get install wget ca-certificates bash git git-crypt -y --no-install-recommends \
|
|
20
|
+
&& wget -q https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/amd64/kubectl -O /usr/local/bin/kubectl \
|
|
21
|
+
&& chmod +x /usr/local/bin/kubectl \
|
|
22
|
+
&& wget -q https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz -O - | tar -xzO linux-amd64/helm > /usr/local/bin/helm \
|
|
23
|
+
&& chmod +x /usr/local/bin/helm \
|
|
24
|
+
&& helm plugin install https://github.com/jkroepke/helm-secrets --version v4.2.2 \
|
|
25
|
+
&& wget -q https://github.com/mozilla/sops/releases/download/v3.7.3/sops-v3.7.3.linux.amd64 -O /usr/local/bin/sops \
|
|
26
|
+
&& chmod +x /usr/local/bin/sops \
|
|
27
|
+
&& apt-get clean \
|
|
28
|
+
&& apt-get -y autoremove \
|
|
29
|
+
&& rm -rf /var/lib/apt/lists/* \
|
|
30
|
+
&& rm -rf /var/cache/apt/ \
|
|
31
|
+
ENV SHELL=/bin/bash
|
|
32
|
+
|
|
33
|
+
##
|
|
34
|
+
## Install dependencies and copy GitOps server.
|
|
35
|
+
##
|
|
36
|
+
WORKDIR /app
|
|
37
|
+
COPY --from=ghcr.io/astral-sh/uv:0.4.0 /uv /bin/uv
|
|
38
|
+
COPY --link=true pyproject.toml uv.lock /app/
|
|
39
|
+
RUN --mount=type=cache,target=/root/.cache/ \
|
|
40
|
+
(uv sync --frozen --no-install-project --extra server || uv sync --frozen --no-install-project --extra server)
|
|
41
|
+
# Install dependencies
|
|
42
|
+
RUN git config --global advice.detachedHead false
|
|
43
|
+
|
|
44
|
+
COPY cluster.key /app/
|
|
45
|
+
COPY gitops /app/gitops/
|
|
46
|
+
COPY gitops_server /app/gitops_server
|
|
47
|
+
|
|
48
|
+
ENV GIT_CRYPT_KEY_FILE=/app/cluster.key
|
|
49
|
+
ENV PYTHONPATH="$PYTHONPATH:/app"
|
|
50
|
+
ENV ACCESS_LOG=""
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
CMD ["uvicorn", "--host", "0.0.0.0", "--port", "8000", "gitops_server.main:app", "--reload"]
|
gitops-0.11.1/PKG-INFO
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: gitops
|
|
3
|
+
Version: 0.11.1
|
|
4
|
+
Summary: Manage multiple apps across one or more k8s clusters.
|
|
5
|
+
Author-email: Jarek Głowacki <jarekwg@gmail.com>
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.12
|
|
8
|
+
Requires-Dist: boto3==1.35.4
|
|
9
|
+
Requires-Dist: colorama>=0.4.4
|
|
10
|
+
Requires-Dist: dsnparse==0.2.1
|
|
11
|
+
Requires-Dist: humanize>=3.5.0
|
|
12
|
+
Requires-Dist: invoke>=2.2.0
|
|
13
|
+
Requires-Dist: packaging>=24.1
|
|
14
|
+
Requires-Dist: pyyaml>=6.0.2
|
|
15
|
+
Requires-Dist: tabulate>=0.8.9
|
|
16
|
+
Provides-Extra: server
|
|
17
|
+
Requires-Dist: fastapi==0.109.2; extra == 'server'
|
|
18
|
+
Requires-Dist: httpx<0.24.0,>=0.23.0; extra == 'server'
|
|
19
|
+
Requires-Dist: kubernetes-asyncio>=25.1.2; extra == 'server'
|
|
20
|
+
Requires-Dist: sentry-sdk>=1.3.0; extra == 'server'
|
|
21
|
+
Requires-Dist: uptick-observability[fastapi]>=0.2.2; extra == 'server'
|
|
22
|
+
Requires-Dist: uvicorn>=0.17.6; extra == 'server'
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# Gitops
|
|
26
|
+
|
|
27
|
+
[](https://pypi.org/project/gitops/)
|
|
28
|
+
[](https://pypi.org/project/gitops/)
|
|
29
|
+
[](https://github.com/uptick/gitops/actions?query=workflow%3ATest)
|
|
30
|
+
[](https://github.com/uptick/gitops/actions?query=workflow%3ALint)
|
|
31
|
+
|
|
32
|
+
Manage multiple apps across one or more k8s clusters.
|
|
33
|
+
|
|
34
|
+
## Overview
|
|
35
|
+
|
|
36
|
+
Keeping track of numerous of single-tenanted application deployments can quickly become a handful. Enter Gitops!
|
|
37
|
+
|
|
38
|
+
The tool has two halves:
|
|
39
|
+
|
|
40
|
+
- Gitops Server - an instance of this gets deployed to each of your kubernetes clusters, listening on changes made to your gitops cluster repo. The server's responsibility is to update the deployments on the cluster it lives on to match the app specifications in the repo.
|
|
41
|
+
- Gitops CLI - this is a tool that you can use to interact comfortably with your cluster repo. It allows listing all deployed applications, what images they're presently running on, and which clusters they live on. It also provides numerous operations that can be applied to one or more apps at a time, such as bumping to a newer version of an image, or running a particular command across your app cohort.
|
|
42
|
+
|
|
43
|
+
You can install the CLI tool with: `pip install gitops`
|
|
44
|
+
|
|
45
|
+
Currently Kubernetes/Helm is the only supported cluster interface. All app deployments are performed as applications of Helm charts.
|
|
46
|
+
|
|
47
|
+
## So what's a "cluster repo"?
|
|
48
|
+
|
|
49
|
+
This is a git repository that you set up, where you list out all of your applications and how you want them deployed. It looks like this:
|
|
50
|
+
|
|
51
|
+
<pre>
|
|
52
|
+
.
|
|
53
|
+
+- apps
|
|
54
|
+
+- app_0
|
|
55
|
+
+- deployment.yml
|
|
56
|
+
+- secrets.yml
|
|
57
|
+
+- app_1
|
|
58
|
+
+- deployment.yml
|
|
59
|
+
+- secrets.yml
|
|
60
|
+
+- jobs
|
|
61
|
+
</pre>
|
|
62
|
+
|
|
63
|
+
## Installation
|
|
64
|
+
|
|
65
|
+
Secrets should be placed in `secrets.env`. The example file `secrets.example.env` has the environment variables you will need to supply.
|
|
66
|
+
|
|
67
|
+
Add `export GITOPS_APPS_DIRECTORY=~/<cluster-apps-folder>` to invoke gitops from any directory.
|
|
68
|
+
|
|
69
|
+
Ensure that gitops has `edit` access to the namespace it is deploying to. An example RoleBinding is:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
apiVersion: rbac.authorization.k8s.io/v1
|
|
73
|
+
kind: RoleBinding
|
|
74
|
+
metadata:
|
|
75
|
+
name: gitops-role-binding
|
|
76
|
+
namespace: workforce
|
|
77
|
+
roleRef:
|
|
78
|
+
apiGroup: rbac.authorization.k8s.io
|
|
79
|
+
kind: ClusterRole
|
|
80
|
+
name: edit
|
|
81
|
+
subjects:
|
|
82
|
+
- kind: ServiceAccount
|
|
83
|
+
name: default
|
|
84
|
+
namespace: gitops
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
# Making a release
|
|
88
|
+
|
|
89
|
+
1. Run `make release` to set tag version the multiple required locations.
|
|
90
|
+
2. Create a github release. Set the release tag to match the version number used. The github pipeline will do the following: Create a new version of the chart, create a docker image and release a new python library version to pypi.
|
gitops-0.11.1/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Gitops
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/gitops/)
|
|
4
|
+
[](https://pypi.org/project/gitops/)
|
|
5
|
+
[](https://github.com/uptick/gitops/actions?query=workflow%3ATest)
|
|
6
|
+
[](https://github.com/uptick/gitops/actions?query=workflow%3ALint)
|
|
7
|
+
|
|
8
|
+
Manage multiple apps across one or more k8s clusters.
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
Keeping track of numerous of single-tenanted application deployments can quickly become a handful. Enter Gitops!
|
|
13
|
+
|
|
14
|
+
The tool has two halves:
|
|
15
|
+
|
|
16
|
+
- Gitops Server - an instance of this gets deployed to each of your kubernetes clusters, listening on changes made to your gitops cluster repo. The server's responsibility is to update the deployments on the cluster it lives on to match the app specifications in the repo.
|
|
17
|
+
- Gitops CLI - this is a tool that you can use to interact comfortably with your cluster repo. It allows listing all deployed applications, what images they're presently running on, and which clusters they live on. It also provides numerous operations that can be applied to one or more apps at a time, such as bumping to a newer version of an image, or running a particular command across your app cohort.
|
|
18
|
+
|
|
19
|
+
You can install the CLI tool with: `pip install gitops`
|
|
20
|
+
|
|
21
|
+
Currently Kubernetes/Helm is the only supported cluster interface. All app deployments are performed as applications of Helm charts.
|
|
22
|
+
|
|
23
|
+
## So what's a "cluster repo"?
|
|
24
|
+
|
|
25
|
+
This is a git repository that you set up, where you list out all of your applications and how you want them deployed. It looks like this:
|
|
26
|
+
|
|
27
|
+
<pre>
|
|
28
|
+
.
|
|
29
|
+
+- apps
|
|
30
|
+
+- app_0
|
|
31
|
+
+- deployment.yml
|
|
32
|
+
+- secrets.yml
|
|
33
|
+
+- app_1
|
|
34
|
+
+- deployment.yml
|
|
35
|
+
+- secrets.yml
|
|
36
|
+
+- jobs
|
|
37
|
+
</pre>
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
Secrets should be placed in `secrets.env`. The example file `secrets.example.env` has the environment variables you will need to supply.
|
|
42
|
+
|
|
43
|
+
Add `export GITOPS_APPS_DIRECTORY=~/<cluster-apps-folder>` to invoke gitops from any directory.
|
|
44
|
+
|
|
45
|
+
Ensure that gitops has `edit` access to the namespace it is deploying to. An example RoleBinding is:
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
apiVersion: rbac.authorization.k8s.io/v1
|
|
49
|
+
kind: RoleBinding
|
|
50
|
+
metadata:
|
|
51
|
+
name: gitops-role-binding
|
|
52
|
+
namespace: workforce
|
|
53
|
+
roleRef:
|
|
54
|
+
apiGroup: rbac.authorization.k8s.io
|
|
55
|
+
kind: ClusterRole
|
|
56
|
+
name: edit
|
|
57
|
+
subjects:
|
|
58
|
+
- kind: ServiceAccount
|
|
59
|
+
name: default
|
|
60
|
+
namespace: gitops
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
# Making a release
|
|
64
|
+
|
|
65
|
+
1. Run `make release` to set tag version the multiple required locations.
|
|
66
|
+
2. Create a github release. Set the release tag to match the version number used. The github pipeline will do the following: Create a new version of the chart, create a docker image and release a new python library version to pypi.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Patterns to ignore when building packages.
|
|
2
|
+
# This supports shell glob matching, relative path matching, and
|
|
3
|
+
# negation (prefixed with !). Only one pattern per line.
|
|
4
|
+
.DS_Store
|
|
5
|
+
# Common VCS dirs
|
|
6
|
+
.git/
|
|
7
|
+
.gitignore
|
|
8
|
+
.bzr/
|
|
9
|
+
.bzrignore
|
|
10
|
+
.hg/
|
|
11
|
+
.hgignore
|
|
12
|
+
.svn/
|
|
13
|
+
# Common backup files
|
|
14
|
+
*.swp
|
|
15
|
+
*.bak
|
|
16
|
+
*.tmp
|
|
17
|
+
*~
|
|
18
|
+
# Various IDEs
|
|
19
|
+
.project
|
|
20
|
+
.idea/
|
|
21
|
+
*.tmproj
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# GitOps Server Helm Chart
|
|
2
|
+
|
|
3
|
+
# Releasing a new version
|
|
4
|
+
|
|
5
|
+
1. Modify `pyproject.toml` and set `version = XXX`
|
|
6
|
+
2. Modify `gitops/__init__.py` and set `__version__ = "XXX"`
|
|
7
|
+
3. Modify `charts/gitops/Chart.yaml` and set `version: "XXX"`
|
|
8
|
+
4. Create a github release. Set the release tag to match `XXX`. The github pipeline will do the following: Create a new version of the chart, create a docker image and release a new python library version to pypi.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{{/* vim: set filetype=mustache: */}}
|
|
2
|
+
{{/*
|
|
3
|
+
Expand the name of the chart.
|
|
4
|
+
*/}}
|
|
5
|
+
{{- define "uptick.name" -}}
|
|
6
|
+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
|
7
|
+
{{- end -}}
|
|
8
|
+
|
|
9
|
+
{{/*
|
|
10
|
+
Create a default fully qualified app name.
|
|
11
|
+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
|
12
|
+
If release name contains chart name it will be used as a full name.
|
|
13
|
+
*/}}
|
|
14
|
+
{{- define "uptick.fullname" -}}
|
|
15
|
+
{{- if .Values.fullnameOverride -}}
|
|
16
|
+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
|
17
|
+
{{- else -}}
|
|
18
|
+
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
|
19
|
+
{{- if contains $name .Release.Name -}}
|
|
20
|
+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
|
|
21
|
+
{{- else -}}
|
|
22
|
+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
|
23
|
+
{{- end -}}
|
|
24
|
+
{{- end -}}
|
|
25
|
+
{{- end -}}
|
|
26
|
+
|
|
27
|
+
{{/*
|
|
28
|
+
Create chart name and version as used by the chart label.
|
|
29
|
+
*/}}
|
|
30
|
+
{{- define "uptick.chart" -}}
|
|
31
|
+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
|
32
|
+
{{- end -}}
|
|
33
|
+
|
|
34
|
+
{{/*
|
|
35
|
+
Create the name of the service account to use
|
|
36
|
+
*/}}
|
|
37
|
+
{{- define "uptick.serviceAccountName" -}}
|
|
38
|
+
{{- if .Values.serviceAccount.create }}
|
|
39
|
+
{{- default (include "uptick.fullname" .) .Values.serviceAccount.name }}
|
|
40
|
+
{{- else }}
|
|
41
|
+
{{- default "default" .Values.serviceAccount.name }}
|
|
42
|
+
{{- end }}
|
|
43
|
+
{{- end }}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{{- if .Values.certificate.install }}
|
|
2
|
+
apiVersion: cert-manager.io/v1alpha2
|
|
3
|
+
kind: Certificate
|
|
4
|
+
metadata:
|
|
5
|
+
name: {{ .Release.Name }}-cert
|
|
6
|
+
spec:
|
|
7
|
+
secretName: gitops-cert-key
|
|
8
|
+
issuerRef:
|
|
9
|
+
name: gitops-issuer
|
|
10
|
+
kind: Issuer
|
|
11
|
+
dnsNames:
|
|
12
|
+
- gitops.{{ .Values.domain }}
|
|
13
|
+
{{- end }}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
apiVersion: apps/v1
|
|
2
|
+
kind: Deployment
|
|
3
|
+
metadata:
|
|
4
|
+
name: {{ .Release.Name }}
|
|
5
|
+
labels:
|
|
6
|
+
app: {{ .Release.Name }}
|
|
7
|
+
service: {{ .Release.Name }}-gitops
|
|
8
|
+
spec:
|
|
9
|
+
replicas: 1
|
|
10
|
+
selector:
|
|
11
|
+
matchLabels:
|
|
12
|
+
app: {{ .Release.Name }}
|
|
13
|
+
strategy:
|
|
14
|
+
type: Recreate
|
|
15
|
+
template:
|
|
16
|
+
metadata:
|
|
17
|
+
labels:
|
|
18
|
+
app: {{ .Release.Name }}
|
|
19
|
+
app.kubernetes.io/name: gitops-server
|
|
20
|
+
app.kubernetes.io/instance: gitops-server-{{ .Release.Name }}
|
|
21
|
+
annotations:
|
|
22
|
+
checksum/environment: {{ include (print $.Template.BasePath "/environment.yml") . | sha256sum }}
|
|
23
|
+
checksum/secrets: {{ include (print $.Template.BasePath "/secrets.yml") . | sha256sum }}
|
|
24
|
+
spec:
|
|
25
|
+
serviceAccountName: {{ include "uptick.serviceAccountName" . }}
|
|
26
|
+
priorityClassName: system-node-critical
|
|
27
|
+
containers:
|
|
28
|
+
- name: gitops
|
|
29
|
+
image: {{ .Values.image }}
|
|
30
|
+
livenessProbe:
|
|
31
|
+
httpGet:
|
|
32
|
+
path: /livez
|
|
33
|
+
port: 8000
|
|
34
|
+
initialDelaySeconds: 5
|
|
35
|
+
failureThreshold: 5
|
|
36
|
+
timeoutSeconds: 10
|
|
37
|
+
periodSeconds: 30
|
|
38
|
+
ports:
|
|
39
|
+
- containerPort: 8000
|
|
40
|
+
resources:
|
|
41
|
+
requests:
|
|
42
|
+
memory: "200Mi"
|
|
43
|
+
limits:
|
|
44
|
+
memory: "1000Mi"
|
|
45
|
+
envFrom:
|
|
46
|
+
- configMapRef:
|
|
47
|
+
name: {{ .Release.Name }}-environment
|
|
48
|
+
env:
|
|
49
|
+
- name: SLACK_URL
|
|
50
|
+
valueFrom:
|
|
51
|
+
secretKeyRef:
|
|
52
|
+
name: {{ .Release.Name }}-secret
|
|
53
|
+
key: SLACK_URL
|
|
54
|
+
- name: SLACK_TOKEN
|
|
55
|
+
valueFrom:
|
|
56
|
+
secretKeyRef:
|
|
57
|
+
name: {{ .Release.Name }}-secret
|
|
58
|
+
key: SLACK_TOKEN
|
|
59
|
+
- name: SENTRY_DSN
|
|
60
|
+
valueFrom:
|
|
61
|
+
secretKeyRef:
|
|
62
|
+
name: {{ .Release.Name }}-secret
|
|
63
|
+
key: SENTRY_DSN
|
|
64
|
+
- name: ACCOUNT_ID
|
|
65
|
+
valueFrom:
|
|
66
|
+
secretKeyRef:
|
|
67
|
+
name: {{ .Release.Name }}-secret
|
|
68
|
+
key: ACCOUNT_ID
|
|
69
|
+
- name: GITHUB_OAUTH_TOKEN
|
|
70
|
+
valueFrom:
|
|
71
|
+
secretKeyRef:
|
|
72
|
+
name: {{ .Release.Name }}-secret
|
|
73
|
+
key: GITHUB_OAUTH_TOKEN
|
|
74
|
+
- name: GITHUB_WEBHOOK_KEY
|
|
75
|
+
valueFrom:
|
|
76
|
+
secretKeyRef:
|
|
77
|
+
name: {{ .Release.Name }}-secret
|
|
78
|
+
key: GITHUB_WEBHOOK_KEY
|
|
79
|
+
volumeMounts:
|
|
80
|
+
- name: git-crypt-key
|
|
81
|
+
mountPath: "/etc/gitops"
|
|
82
|
+
readOnly: true
|
|
83
|
+
volumes:
|
|
84
|
+
- name: git-crypt-key
|
|
85
|
+
secret:
|
|
86
|
+
secretName: {{ .Release.Name }}-secret
|
|
87
|
+
items:
|
|
88
|
+
- key: GIT_CRYPT_KEY
|
|
89
|
+
path: git_crypt_key
|
|
90
|
+
restartPolicy: Always
|
|
91
|
+
|
|
92
|
+
{{- if .Values.nodeSelector }}
|
|
93
|
+
nodeSelector:
|
|
94
|
+
{{ toYaml .Values.nodeSelector | indent 8 }}
|
|
95
|
+
{{- end }}
|
|
96
|
+
{{- if .Values.affinity }}
|
|
97
|
+
affinity:
|
|
98
|
+
{{ toYaml .Values.affinity | indent 8 }}
|
|
99
|
+
{{- end }}
|
|
100
|
+
{{- if .Values.tolerations }}
|
|
101
|
+
tolerations:
|
|
102
|
+
{{ toYaml .Values.tolerations | indent 6 }}
|
|
103
|
+
{{- end }}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
apiVersion: networking.k8s.io/v1
|
|
2
|
+
kind: Ingress
|
|
3
|
+
metadata:
|
|
4
|
+
name: {{ .Release.Name }}-ingress
|
|
5
|
+
namespace: {{ .Release.Namespace }}
|
|
6
|
+
labels:
|
|
7
|
+
app: {{ .Release.Name }}
|
|
8
|
+
annotations:
|
|
9
|
+
{{- if .Values.certificate.install }}
|
|
10
|
+
certmanager.k8s.io/cluster-issuer: http-issuer
|
|
11
|
+
{{- end }}
|
|
12
|
+
ingress.kubernetes.io/ssl-redirect: "true"
|
|
13
|
+
{{- range $key, $value := .Values.ingress.annotations }}
|
|
14
|
+
{{ $key }}: {{ $value | quote }}
|
|
15
|
+
{{- end }}
|
|
16
|
+
spec:
|
|
17
|
+
tls:
|
|
18
|
+
- secretName: gitops-cert-key
|
|
19
|
+
rules:
|
|
20
|
+
- host: {{ .Values.domain }}
|
|
21
|
+
http:
|
|
22
|
+
paths:
|
|
23
|
+
- backend:
|
|
24
|
+
service:
|
|
25
|
+
name: {{ .Release.Name }}-service
|
|
26
|
+
port:
|
|
27
|
+
number: 80
|
|
28
|
+
path: /
|
|
29
|
+
pathType: Prefix
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{{- if .Values.certificate.install }}
|
|
2
|
+
apiVersion: cert-manager.io/v1alpha2
|
|
3
|
+
kind: Issuer
|
|
4
|
+
metadata:
|
|
5
|
+
name: gitops-issuer
|
|
6
|
+
spec:
|
|
7
|
+
acme:
|
|
8
|
+
server: https://acme-v02.api.letsencrypt.org/directory
|
|
9
|
+
email: "info@uptickhq.com"
|
|
10
|
+
privateKeySecretRef:
|
|
11
|
+
name: gitops-issuer-key
|
|
12
|
+
solvers:
|
|
13
|
+
- http01:
|
|
14
|
+
ingress:
|
|
15
|
+
class: nginx
|
|
16
|
+
{{- end }}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
apiVersion: v1
|
|
2
|
+
kind: Secret
|
|
3
|
+
metadata:
|
|
4
|
+
name: {{ .Release.Name }}-secret
|
|
5
|
+
type: Opaque
|
|
6
|
+
stringData:
|
|
7
|
+
ACCOUNT_ID: {{ .Values.secrets.ACCOUNT_ID | quote}}
|
|
8
|
+
SLACK_URL: {{ .Values.secrets.SLACK_URL| quote}}
|
|
9
|
+
GITHUB_OAUTH_TOKEN: {{ .Values.secrets.GITHUB_OAUTH_TOKEN| quote}}
|
|
10
|
+
GITHUB_WEBHOOK_KEY: {{ .Values.secrets.GITHUB_WEBHOOK_KEY| quote}}
|
|
11
|
+
SENTRY_DSN: {{ .Values.secrets.SENTRY_DSN| quote}}
|
|
12
|
+
SLACK_TOKEN: {{ .Values.secrets.SLACK_TOKEN| quote}}
|
|
13
|
+
data:
|
|
14
|
+
GIT_CRYPT_KEY: {{ .Values.secrets.GIT_CRYPT_KEY | quote}}
|