Skip to content

K8s operator for configuring Cloudflare Zero Trust ☁️ ⚡ 🔐

License

Notifications You must be signed in to change notification settings

asychev/cloudflare-zero-trust-operator

 
 

Repository files navigation

Cloudflare Zero-Trust Operator

This is very early alpha project and not finalized yet & is therefore still a work in progess. Expect breaking changes

Cloudflare Zero-Trust operator allow you to manage your zero-trust configuration directly from kubernetes

Version: 0.3.0 CRD - reference Unit Tests Go Report Card PkgGoDev codecov

Example Usage

Cloudflare Access Group

apiVersion: cloudflare.zelic.io/v1alpha1
kind: CloudflareAccessGroup
metadata:
  name: accessgroup-example
  annotations:
    # (optional) default: "false"
    #   ensures that the resource isn't removed from cloudflare if the CR is deleted
    cloudflare.zelic.io/prevent-destroy: "true"
spec:
  name: my access group
  include:
    - emails:
      - [email protected]
      - [email protected]
apiVersion: cloudflare.zelic.io/v1alpha1
kind: CloudflareAccessApplication
metadata:
  name: domain-example
  annotations:
    # (optional) default: "false"
    #   ensures that the resource isn't removed from cloudflare if the CR is deleted
    cloudflare.zelic.io/prevent-destroy: "true"
spec:
  name: my application
  domain: domain.example.com
  autoRedirectToIdentity: true
  policies: 
    - name: Allow testemail1
      decision: allow
      include:
        - emails:
          - [email protected]

Example App

Features

Currently in Project scope

  • Manage Cloudflare Access Groups
  • Manage Cloudflare Access Applications
  • Manage Cloudflare Access Tokens

Advanced Usage

See some more examples of how to use the cloudflare zero-trust operator here

Install

Token Permissions

On your Cloudflare Dashboard; Create a custom API token with the following permissions:

  • Access: Service Tokens:Edit
  • Access: Organizations, Identity Providers, and Groups: Edit
  • Access: Apps and Policies:Edit

This token will be used referenced as CLOUDFLARE_API_TOKEN in the secret below;

Install with Helm

  1. Create your namespace
kubectl create ns zero-trust-system
  1. Create a secret with your cloudflare credentials
apiVersion: v1
metadata:
  name: cloudflare-creds
  namespace: zero-trust-system
kind: Secret
type: Opaque
stringData:
  CLOUDFLARE_ACCOUNT_ID: <id>
  # Either EMAIL+KEY or TOKEN must be supplied
  # note: keys must still be defined even if they are empty
  CLOUDFLARE_API_EMAIL: <email>
  CLOUDFLARE_API_KEY: <api_key>
  CLOUDFLARE_API_TOKEN: <api_token>
  1. Install the helm repo
helm repo add zelic-io https://zelic-io.github.io/charts
 
helm install --namespace=zero-trust-system --set secretRef=cloudflare-creds cloudflare-zero-trust-operator zelic-io/cloudflare-zero-trust-operator

Install with Kustomize

kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - https://github.com/BojanZelic/cloudflare-zero-trust-operator//config/default?ref=main

secretGenerator:
- name: cloudflare-creds
  literals:
    - CLOUDFLARE_API_KEY=""
    - CLOUDFLARE_API_EMAIL=""
    - CLOUDFLARE_ACCOUNT_ID=""
    - CLOUDFLARE_API_TOKEN=""

Compatability

This provider's versions are able to install and manage the following versions of Kubernetes:

v1.22 v1.23 v1.24 v1.25 v1.26
Cloudflare Zero Trust Operator v0.0.1-current

Local Development

cp .env.example .env.integration
vim .env.integration # add your creds here
make integration-test

License

Copyright 2022.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

K8s operator for configuring Cloudflare Zero Trust ☁️ ⚡ 🔐

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 88.2%
  • Makefile 9.2%
  • Smarty 1.6%
  • Other 1.0%