-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* reconcile non-root and non-privileged overlays
- Loading branch information
Showing
54 changed files
with
77 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
overlays/migrate-to-nonroot/README.md → overlays/migrate-to-nonprivileged/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion
4
...ays/migrate-to-nonroot/kustomization.yaml → ...grate-to-nonprivileged/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,32 @@ | ||
This kustomization is for Sourcegraph installations in clusters with security restrictions. | ||
It avoids creating `Roles` and does all the rolebinding in a namespace. It configures Prometheus to work in the namespace | ||
and not require ClusterRole wide privileges when doing service discovery for scraping targets. It also disables cAdvisor. | ||
This kustomization is for creating fresh Sourcegraph installations that want to run containers as non-root users in clusters with security restrictions. | ||
It avoids creating Roles and does all the rolebinding in a namespace. It configures Prometheus to work in the namespace and not require ClusterRole wide privileges when doing service discovery for scraping targets. It also disables cAdvisor. | ||
|
||
This version and `non-privileged` need to stay in sync. This version is only used for cluster creation. | ||
This version and non-privileged need to stay in sync. This version is only used for cluster creation. | ||
|
||
To use it, execute the following command from the root directory of this repository: | ||
This kustomization injects a fsGroup security context in each pod so that the volumes are mounted with the | ||
specified supplemental group id and non-root pod users can write to the mounted volumes. | ||
|
||
This is only done once at cluster creation time so this overlay is only referenced by the `create-new-cluster.sh` | ||
script. | ||
|
||
The reason for this approach is the behavior of fsGroup: on every mount it recursively chmod/chown the disk to add | ||
the group specified by fsGroup and to change permissions to 775 (so group can write). This can take a long time for | ||
large disks and sometimes times out the whole pod scheduling. | ||
|
||
If we only do it at cluster creation time (when the disks are empty) it is fast and since the disks are persistent | ||
volumes we know that the pod user can write to it even without the fsGroup and subsequent apply operations. | ||
|
||
In Kubernetes 1.18 fsGroup gets an additional [feature](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#configure-volume-permission-and-ownership-change-policy-for-pods) | ||
called `fsGroupChangePolicy` that will allow us to control the chmod/chown better. | ||
|
||
To use it execute the following command from the root directory of this repository: | ||
|
||
```shell script | ||
./overlay-generate-cluster.sh non-privileged generated-cluster | ||
./overlay-generate-cluster.sh non-privileged-create-cluster generated-cluster | ||
``` | ||
|
||
After executing the script you can apply the generated manifests from the `generated-cluster` directory: | ||
|
||
```shell script | ||
kubectl create namespace ns-sourcegraph | ||
kubectl apply -n ns-sourcegraph --prune -l deploy=sourcegraph -f generated-cluster --recursive | ||
kubectl apply --prune -l deploy=sourcegraph -f generated-cluster --recursive | ||
``` |
File renamed without changes.
File renamed without changes.
16 changes: 0 additions & 16 deletions
16
overlays/non-privileged-create-cluster/frontend/sourcegraph-frontend.RoleBinding.yaml
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
75 changes: 0 additions & 75 deletions
75
overlays/non-privileged-create-cluster/prometheus/prometheus.ConfigMap.yaml
This file was deleted.
Oops, something went wrong.
File renamed without changes.
16 changes: 0 additions & 16 deletions
16
overlays/non-privileged-create-cluster/prometheus/prometheus.RoleBinding.yaml
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters