Common Network Policy Operator is auto create common network policy to all namespaces.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmd/manager
config
hack
pkg
vendor
.gitignore
Dockerfile
Gopkg.lock
Gopkg.toml
LICENSE
Makefile
PROJECT
README.md

README.md

Common Network Policy Operator

MIT License Go Report Card

Common Policy Operator is auto create common network policy to all namespaces.

Requirement

  • kubectl
  • Kustomize

Installation

$ kubectl config current-context <TARGET CLUSTER CONTEXT>
$ git@github.com:bells17/common-network-policy-operator.git
$ cd common-network-policy-operator
$ make deploy

If install is success, you can check resources as below:

$ kubectl get po -n common-network-policy-operator-system
NAME                                                     READY     STATUS    RESTARTS   AGE
common-network-policy-operator-controller-manager-0   1/1       Running   0          1m

$ kubectl get crd
NAME                                                           CREATED AT
commonnetworkpolicies.commonnetworkpolicies.bells17.io   2018-11-09T00:00:00Z

Usage

You can apply to your cluster using the following example.

apiVersion: commonnetworkpolicies.bells17.io/v1alpha1
kind: CommonNetworkPolicy
metadata:
  labels:
    controller-tools.k8s.io: "1.0"
  name: sample-networkpolicy
spec:
  namePrefix: common
  excludeNamespaces:
  - kube-system
  - common-network-policy-operator-system
  policySpec:
    podSelector: {}
    policyTypes:
    - Egress

---
apiVersion: commonnetworkpolicies.bells17.io/v1alpha1
kind: CommonNetworkPolicy
metadata:
  labels:
    controller-tools.k8s.io: "1.0"
  name: sample-networkpolicy2
spec:
  namePrefix: common
  excludeNamespaces:
  - kube-system
  - common-network-policy-operator-system
  policySpec:
    podSelector: {}
    ingress:
    - {}

After apply, create commonnetworkpolicies and networkpolicies such as below:

$ kubectl get commonnetworkpolicies
NAME                    CREATED AT
sample-networkpolicy    1m
sample-networkpolicy2   1m

$ kubectl get networkpolicies --all-namespaces=true
NAMESPACE     NAME                              POD-SELECTOR   AGE
default       common-sample-networkpolicy    <none>         1m
default       common-sample-networkpolicy2   <none>         1m
docker        common-sample-networkpolicy    <none>         1m
docker        common-sample-networkpolicy2   <none>         1m
kube-public   common-sample-networkpolicy    <none>         1m
kube-public   common-sample-networkpolicy2   <none>         1m

LICENSE

Copyright 2018 bells17.

Licensed under the MIT License.