Skip to main content

cdk8s-flux

Manage your kubernetes cluster in a GitOps fashion with Flux, construct library for cdk8s project🚀

Overview

cdk8s-flux is a cdk8s library which allows you to deploy define a installation of a Flux daemon in your kubernetes cluster with just a few lines of code. This could be used as an alternative to the Flux Helm Chart or the fluxctl install command.

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
Flux(self, "flux",
    ns="flux",
    name="flux",
    image="fluxcd/flux",
    tag="1.19.0",
    replicas=1,
    arguments=["--memcached-service=", "--ssh-keygen-dir=/etc/fluxd/keygen", "--git-url=git@github.com:rafaribe/cdk8s-k3s-gitops.git", "--git-branch=master", "--git-path=cluster", "--git-label=flux", "--git-user=flux", "--git-email=flux@rafaribe.com", "--git-poll-interval=5m", "--sync-garbage-collection"
    ]
)
flux.k8s.yaml
apiVersion: v1
kind: Namespace
metadata:
  labels:
    name: flux
  name: flux
---
apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
    name: flux
  name: flux
  namespace: flux
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  labels:
    name: flux
  name: flux
rules:
  - apiGroups:
      - "*"
    resources:
      - "*"
    verbs:
      - "*"
  - nonResourceURLs:
      - "*"
    verbs:
      - "*"
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  labels:
    name: flux
  name: flux
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: flux
subjects:
  - kind: ServiceAccount
    name: flux
    namespace: flux
---
apiVersion: v1
kind: Secret
metadata:
  name: flux-git-deploy
  namespace: flux
type: Opaque
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: flux
  namespace: flux
spec:
  replicas: 1
  selector:
    matchLabels:
      name: flux
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        name: flux
    spec:
      containers:
        - args:
            - --memcached-service=
            - --ssh-keygen-dir=/etc/fluxd/keygen
            - --git-url=git@github.com:rafaribe/cdk8s-k3s-gitops.git
            - --git-branch=master
            - --git-path=cluster
            - --git-label=flux
            - --git-user=flux
            - --git-email=flux@rafaribe.com
            - --git-poll-interval=5m
            - --sync-garbage-collection
          image: raspbernetes/flux:1.19.0
          imagePullPolicy: IfNotPresent
          livenessProbe:
            httpGet:
              path: api/flux/v6/identity.pub
              port: 3030
            initialDelaySeconds: 5
            timeoutSeconds: 5
          name: flux
          ports:
            - containerPort: 3030
          readinessProbe:
            httpGet:
              path: api/flux/v6/identity.pub
              port: 3030
            initialDelaySeconds: 5
            timeoutSeconds: 5
          resources:
            limits:
              cpu: 150m
              memory: 256Mi
          volumeMounts:
            - mountPath: /etc/fluxd/ssh
              name: git-key
              readOnly: true
            - mountPath: /etc/fluxd/keygen
              name: git-keygen
      serviceAccountName: flux
      volumes:
        - name: git-key
          secret:
            defaultMode: 256
            secretName: flux-git-deploy
        - emptyDir:
            medium: Memory
          name: git-keygen
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: memcached
  namespace: flux
spec:
  replicas: 1
  selector:
    matchLabels:
      name: memcached
  template:
    metadata:
      labels:
        name: memcached
    spec:
      containers:
        - args:
            - -m 512
            - -I 5m
            - -p 11211
          image: memcached:1.5.20
          name: memcached
          ports:
            - containerPort: 11211
              name: clients
          securityContext:
            allowPrivilegeEscalation: false
            runAsGroup: 11211
            runAsUser: 11211
---
apiVersion: v1
kind: Service
metadata:
  name: memcached
  namespace: flux
spec:
  ports:
    - name: memcached
      port: 11211
  selector:
    name: memcached

Installation

cdk8s supports TypeScript and Python at this point, so as cdk8s-flux.

We'd recommend to walk through the cdk8s Getting Started guide before using this library, if you're very new to cdk8s world.

TypeScript

Use npm or yarn to install.

$ npm install -s cdk8s-flux

or

$ yarn add cdk8s-flux

Python

$ pip install cdk8s-flux

Contribution

  1. Fork (https://github.com/rafaribe/cdk8s-flux/fork)

  2. Bootstrap the repo:

    yarn install # installs dependencies
    
  3. Development scripts:

Command Description
yarn compile Compiles jsii
yarn watch Watch & compile
yarn test Runs the jest unit tests
yarn test -u Updates jest snapshots
yarn run package Outputs the jsii generated packages in TS and Python
yarn build Compile + Test + Package
yarn bump Bumps version
yarn release Bump + push to master
yarn rmist Deletes node_modules and runs installs dependencies
yarn lint Lint with eslinter
yarn prettier Runs prettier and updates the files in place
yarn run import cdk8s imports k8s and crds into the imports directory
  1. Create a feature branch
  2. Commit your changes
  3. Rebase your local changes against the master branch
  4. Create a new Pull Request (use conventional commits for the title please)

License

Apache License, Version 2.0

Author

Rafael Ribeiro

Thank you:

Thank you to the devs of the following projects, from where I got some inspiration to create this library:

Metadata

Release files for cdk8s-flux 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cdk8s-flux 0.1.3
File Size Uploaded Provenance Actions
cdk8s-flux-0.1.3.tar.gz 275.7 kB Without provenance Details for cdk8s-flux-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cdk8s-flux 0.1.3
File Interpreter ABI Platform Actions
cdk8s_flux-0.1.3-py3-none-any.whl Python 3 none any Details for cdk8s_flux-0.1.3-py3-none-any.whl

Total release size: 549.2 kB

Release files / cdk8s-flux-0.1.3.tar.gz

Download URL cdk8s-flux-0.1.3.tar.gz
Size 275.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6894e0ad7379a7a155c8edb27eced0bae6ec39fd40512dd09e94c1ed19e300b9
BLAKE2b-256 checksum
How to use checksums
f2c1b7f73f039f039e71e1d240b176aa5ac72713f20f36b9c1af55f9d6df794a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6

Release files / cdk8s_flux-0.1.3-py3-none-any.whl

Download URL cdk8s_flux-0.1.3-py3-none-any.whl
Size 273.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3487530adaa97d708dbb0d266d63aae52dbc3483e070c829425bdb1eebadee5
BLAKE2b-256 checksum
How to use checksums
be60505c2959f340b986c63322b5c0788345b468a3831e5406ede59540712185
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6

Security for cdk8s-flux 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page