Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Commit

Permalink
Add network policies change
Browse files Browse the repository at this point in the history
Adding network policies restriction to the openfaas and
the openfaas-fn namespaces introduced by Matias in the
openfaas-cloud repo

Signed-off-by: Martin Dekov <[email protected]>
  • Loading branch information
martindekov authored and alexellis committed May 30, 2019
1 parent f17475e commit d7e9177
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ If you are planning on building functions using the `dockerfile` template you ne
#### Enable scaling to zero
If you want your functions to scale to zero then you need to set `scale_to_zero: true`.

#### Toggle network policies

Network policies restriction for the openfaas and openfaas-fn namespaces are applied by default. If you would like to remove that restriction set `network_policies: false`.

When deployed, network policies restrict communication so that functions cannot talk to the core OpenFaaS components in the `openfaas` namespace. They also prevent functions from invoking each other directly. It is recommended to enable this feature.

### Run the `ofc-bootstrap`

```bash
Expand Down
3 changes: 3 additions & 0 deletions example.init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,6 @@ enable_dockerfile_lang: false
# Set to true to enable scaling to zero
scale_to_zero: false
openfaas_cloud_version: 0.9.4

# Enable network policies
network_policies: true
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,11 +607,15 @@ func deployCloudComponents(plan types.Plan) error {
if plan.SCM == "gitlab" {
gitlabEnv = "GITLAB=true"
}
networkPoliciesEnv := ""
if plan.NetworkPolicies {
networkPoliciesEnv = "ENABLE_NETWORK_POLICIES=true"
}

task := execute.ExecTask{
Command: "./scripts/deploy-cloud-components.sh",
Shell: true,
Env: []string{authEnv, gitlabEnv},
Env: []string{authEnv, gitlabEnv, networkPoliciesEnv},
}

res, err := task.Execute()
Expand Down
1 change: 1 addition & 0 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type Plan struct {
EnableDockerfileLang bool `yaml:"enable_dockerfile_lang"`
ScaleToZero bool `yaml:"scale_to_zero"`
OpenFaaSCloudVersion string `yaml:"openfaas_cloud_version"`
NetworkPolicies bool `yaml:"network_policies"`
}

// Deployment is the deployment section of YAML concerning
Expand Down
3 changes: 3 additions & 0 deletions scripts/deploy-cloud-components.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ kubectl apply -f ./tmp/openfaas-cloud/yaml/core/edge-router-svc.yml

kubectl apply -f ./tmp/openfaas-cloud/yaml/core/edge-auth-svc.yml

if [ "$ENABLE_NETWORK_POLICIES" = "true" ] ; then
kubectl apply -f ./tmp/openfaas-cloud/yaml/network-policy/
fi

cd ./tmp/openfaas-cloud

Expand Down

0 comments on commit d7e9177

Please sign in to comment.