Securing a service network using policies
By default, Skupper includes many security features, including using mutual TLS for all service network communication between sites. By default, applying the policy system to a cluster prevents all service network communication to and from that cluster. You specify granular policies to allow only the service network communication you require.
The policy system is distinct from the network-policy option which restricts access to Skupper services to the current namespace as described in Configuring Skupper sites using the CLI.
|
Each site in a service network runs a Skupper router and has a private, dedicated certificate authority (CA). Communication between sites is secured with mutual TLS, so the service network is isolated from external access, preventing security risks such as lateral attacks, malware infestations, and data exfiltration. The policy system adds another layer at a cluster level to help a cluster administrator control access to a service network.
This guide assumes that you understand the following Skupper concepts:
- site
-
A namespace in which Skupper is installed.
- token
-
A token is required to establish a link between two sites.
- service network
-
After exposing services using Skupper, you have created a service network.
About the policy system
After a cluster administrator installs the policy system using a Custom Resource Definition (CRD), the cluster administrator needs to configure one or more policies to allow developers create and use services on the service network.
In this guide, developers refers to users of a cluster who have access to a namespace, but do not have administrator privileges. |
A cluster administrator configures one or more of following items using custom resources (CRs) to enable communication:
- Allow incoming links
-
Use
allowIncomingLinks
to enable developers create tokens and configure incoming links. - Allow outgoing links to specific hosts
-
Use
allowedOutgoingLinksHostnames
to specify hosts that developers can create links to. - Allow services
-
Use
allowedServices
to specify which services developers can create or use on the service network. - Allow resources to be exposed
-
Use
allowedExposedResources
to specify which resources a developer can expose on the service network.
A cluster administrator can apply each policy CR setting to one or more namespaces. |
For example, the following policy CR fully allows all Skupper capabilities on all namespaces, except for:
-
only allows outgoing links to any domain ending in
.example.com
. -
only allows 'deployment/nginx' resources to be exposed on the service network.
apiVersion: skupper.io/v1alpha1
kind: SkupperClusterPolicy
metadata:
name: cluster-policy-sample-01
spec:
namespaces:
- "*"
allowIncomingLinks: true
allowedExposedResources:
- "deployment/nginx"
allowedOutgoingLinksHostnames: [".*\\.example.com$"]
allowedServices:
- "*"
You can apply many policy CRs, and if there are conflicts in the items allowed, the most permissive policy is applied.
For example, if you apply an additional policy CR with the line |
namespaces
-
One or more patterns to specify the namespaces that this policy applies to. Note that you can use Label selectors to match the namespaces.
allowIncomingLinks
-
Specify
true
to allow other sites create links to the specified namespaces. allowedOutgoingLinksHostnames
-
Specify one or more patterns to determine which hosts you can create links to from the specified namespaces.
allowedServices
-
Specify one or more patterns to determine the permitted names of services allowed on the service network from the specified namespaces.
allowedExposedResources
-
Specify one or more permitted names of resources allowed on the service network from the specified namespaces. Note that patterns are not supported.
Use regular expressions to create pattern matches, for example:
|
If you create another CR that allows outgoing links for a specific namespace, a user can create a link from that namespace to join a service network. That is, the logic for multiple policy CRs is OR
.
An operation is permitted if any single policy CR permits the operation.
Installing the policy system CRD
Installing the policy system CRD enables a cluster administrator to enforce policies for service networks.
If there are existing sites on the cluster, see Installing the policy system CRD on a cluster with existing sites to avoid service network disruption. |
-
Access to a cluster using a
cluster-admin
account -
The Skupper operator is installed
-
Log in to the cluster using a
cluster-admin
account. -
Download the CRD:
$ wget https://raw.githubusercontent.com/skupperproject/skupper/1.0/api/types/crds/skupper_cluster_policy_crd.yaml
-
Apply the CRD:
$ kubectl apply -f skupper_cluster_policy_crd.yaml customresourcedefinition.apiextensions.k8s.io/skupperclusterpolicies.skupper.io created clusterrole.rbac.authorization.k8s.io/skupper-service-controller created
-
To verify that the policy system is active, use the
skupper status
command and check that the output includes the following line:Skupper is enabled for namespace "<namespace>" in interior mode (with policies).
Upgrading on a cluster with existing sites
If you are upgrading sites from Skupper version 0.8, you can take advantage of the lack of a policy system in that version and avoid service network disruption.
-
Document each service and exposed resources.
-
Create policy CRs as described in Creating policies for the policy system
-
Install the CRD as described in Installing the policy system CRD.
-
Grant permissions to read policies to developers to avoid that site being blocked from the service network.
For each site namespace:
$ kubectl create clusterrolebinding skupper-service-controller-<namespace> --clusterrole=skupper-service-controller --serviceaccount=<namespace>:skupper-service-controller
where
<namespace>
is the site namespace.
Installing the policy system CRD on a cluster with existing sites
If the cluster already hosts Skupper sites, note the following before installing the CRD:
-
All existing connections are closed. You must apply a policy CR to reopen connections.
-
All existing service network services and exposed resources are removed. You must create those resources again.
If you are upgrading sites from Skupper version 0.8, you can take advantage of the lack of a policy system in that version and avoid service network disruption by following the procedure described in Upgrading on a cluster with existing sites. |
To avoid disruption:
-
Plan the CRD deployment for an appropriate time.
-
Search your cluster for sites:
$ kubectl get pods --all-namespaces --selector=app=skupper
-
Document each service and resource exposed on the service network.
-
Install the CRD as described in Installing the policy system CRD. This step closes connections and removes all service network services and exposed resources.
-
If Skupper sites exist in the cluster not created by
cluster-admin
, you must grant permissions to read policies to developers to avoid that site being blocked from the service network.For each site namespace:
$ kubectl create clusterrolebinding skupper-service-controller-<namespace> --clusterrole=skupper-service-controller --serviceaccount=<namespace>:skupper-service-controller
where
<namespace>
is the site namespace. -
Create policy CRs as described in Creating policies for the policy system
-
Recreate any services and exposed resources as required.
Creating policies for the policy system
Policies allow a cluster administrator to control communication across the service network from a cluster.
-
Access to a cluster using a
cluster-admin
account. -
The policy system CRD is installed on the cluster.
Procedure
Typically, you create a policy CR that combines many elements from the steps below. See About the policy system for an example CR.
|
Implement a policy to allow incoming links
Use allowIncomingLinks
to enable developers create tokens and configure incoming links.
-
Determine which namespaces you want to apply this policy to.
-
Create a CR with
allowIncomingLinks
set totrue
orfalse
. -
Create and apply the CR.
For example, the following CR allows incoming links for all namespaces:
apiVersion: skupper.io/v1alpha1
kind: SkupperClusterPolicy
metadata:
name: allowincominglinks
spec:
namespaces:
- "*"
allowIncomingLinks: true
Implement a policy to allow outgoing links to specific hosts
Use allowedOutgoingLinksHostnames
to specify hosts that developers can create links to.
You cannot create a allowedOutgoingLinksHostnames
policy to disallow a specific host that was previously allowed.
-
Determine which namespaces you want to apply this policy to.
-
Create a CR with
allowedOutgoingLinksHostnames
set to a pattern of allowed hosts. -
Create and apply the CR.
For example, the following CR allows links to all subdomains of example.com
for all namespaces:
apiVersion: skupper.io/v1alpha1
kind: SkupperClusterPolicy
metadata:
name: allowedoutgoinglinkshostnames
spec:
namespaces:
- "*"
allowedOutgoingLinksHostnames: ['.*\\.example\\.com']
Implement a policy to allow specific services
Use allowedServices
to specify which services a developer can create or use on the service network.
You cannot create a allowedServices
policy to disallow a specific service that was previously allowed.
-
Determine which namespaces you want to apply this policy to.
-
Create a CR with
allowedServices
set to specify the services allowed on the service network. -
Create and apply the CR.
For example, the following CR allows users to expose and consume services with the prefix backend-
for all namespaces:
apiVersion: skupper.io/v1alpha1
kind: SkupperClusterPolicy
metadata:
name: allowedservices
spec:
namespaces:
- "*"
allowedServices: ['^backend-']
When exposing services, you can use the --address <name> parameter of the skupper CLI to name services to match your policy.
|
Implement a policy to allow specific resources
Use allowedExposedResources
to specify which resources a developer can expose on the service network.
You cannot create a allowedExposedResources
policy to disallow a specific resource that was previously allowed.
-
Determine which namespaces you want to apply this policy to.
-
Create a CR with
allowedExposedResources
set to specify resources that a developer can expose on the service network. -
Create and apply the CR.
For example, the following CR allows you to expose an nginx
deployment for all namespaces:
apiVersion: skupper.io/v1alpha1
kind: SkupperClusterPolicy
metadata:
name: allowedexposedresources
spec:
namespaces:
- "*"
allowedExposedResources: ['deployment/nginx']
For allowedExposedResources , each entry must conform to the type/name syntax.
|
Exploring the current policies for a cluster
As a developer you might want to check which policies are enforced for a particular site.
-
Log into a namespace where a Skupper site has been initialized.
-
Check whether incoming links are permitted:
$ kubectl exec deploy/skupper-service-controller -- get policies incominglink ALLOWED POLICY ENABLED ERROR ALLOWED BY false true Policy validation error: incoming links are not allowed
In this example incoming links are not allowed by policy.
-
Explore other policies:
$ kubectl exec deploy/skupper-service-controller -- get policies Validates existing policies Usage: get policies [command] Available Commands: expose Validates if the given resource can be exposed incominglink Validates if incoming links can be created outgoinglink Validates if an outgoing link to the given hostname is allowed service Validates if service can be created or imported
As shown, there are commands to check each policy type by specifying what you want to do, for example, to check if you can expose an nginx deployment:
$ kubectl exec deploy/skupper-service-controller -- get policies expose deployment nginx ALLOWED POLICY ENABLED ERROR ALLOWED BY false true Policy validation error: deployment/nginx cannot be exposed
If you allowed an nginx deployment as described in Implement a policy to allow specific resources, the same command shows that the resource is allowed and displays the name of the policy CR that enabled it:
$ kubectl exec deploy/skupper-service-controller -- get policies expose deployment nginx ALLOWED POLICY ENABLED ERROR ALLOWED BY true true allowedexposedresources