Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add k8s rbac minimal config #278

Merged
merged 3 commits into from
Apr 1, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 54 additions & 2 deletions docs/service-discovery/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,61 @@ First, you need to add the Stork Kubernetes Service Discovery provider:
</dependency>
```

####A few words about server authentication.
Stork uses Fabric8 Kubernetes Client to access the Kubernetes resources, concretely the `DefaultKubernetesClient` implementation. It will try to read the ~/.kube/config file in your home directory and load information required for authenticating with the Kubernetes API server. If you are using DefaultKubernetesClient from inside a Pod, it will load ~/.kube/config from the ServiceAccount volume mounted inside the Pod. You can override this configuration if you want a more complex configuration.
#### A few words about server authentication.
Stork uses [Fabric8 Kubernetes Client](https://github.com/fabric8io/kubernetes-client#readme) to access the Kubernetes resources, concretely the `DefaultKubernetesClient` implementation.

Stork uses Fabric8 Kubernetes Client to access the Kubernetes resources, concretely the `DefaultKubernetesClient` implementation.
aureamunoz marked this conversation as resolved.
Show resolved Hide resolved

It will try to read the `~/.kube/config` file from your local machine and load the token for authenticating with the Kubernetes API server.

If you are using the Stork Kubernetes discovery provider from inside a _Pod_, it load `~/.kube/config` from the container file system.
aureamunoz marked this conversation as resolved.
Show resolved Hide resolved

aureamunoz marked this conversation as resolved.
Show resolved Hide resolved
This file is automatically mounted inside the Pod.

The level of access (Roles) depends on the configured `ServiceAccount`.

You can override this configuration if you want fine-grain control.

##### Role-based access control (RBAC)
If you're using a Kubernetes cluster with Role-Based Access Control (RBAC) enabled, the default permissions for a ServiceAccount don't allow it to list or modify any resources.
A `ServiceAccount`, a `Role` and a `RoleBinding` are needed in order to allow Stork to list the available service instances from the cluster or the namespace.

An example that allows listing all endpoints could look something like this:

```yaml
------
apiVersion: v1
kind: ServiceAccount
metadata:
name: <appname>
namespace: <namespace>
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: <appname>
aureamunoz marked this conversation as resolved.
Show resolved Hide resolved
namespace: <namespace>
rules:
- apiGroups: [""] # "" indicates the core API group
resources: ["endpoints"] # stork queries service endpoints
verbs: ["get", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
name: <appname>
namespace: <namespace>
subjects:
- kind: ServiceAccount
# Reference to upper's `metadata.name`
name: <appname>
# Reference to upper's `metadata.namespace`
namespace: <namespace>
roleRef:
kind: Role
name: <appname>
apiGroup: rbac.authorization.k8s.io
```

## Configuration

Expand Down