Skip to content

Commit 821032e

Browse files
authored
switch away from user 0 (root) and delete unnecessary cluster role (sourcegraph#534)
* switch away from user 0 (root) and delete unnecessary cluster role binding * pgsql data dir tweak * avoid chown when already correct * extract initContainers into kustomization (sourcegraph#537) * migrate doc * buildkite checks accommodate kustomize * kubectl version is not working * asas !!!!! * migrate doc specifies kubectl version
1 parent 7a19888 commit 821032e

32 files changed

+276
-56
lines changed

.buildkite/hooks/pre-command

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ cd $BUILDKITE_BUILD_CHECKOUT_PATH
55

66
echo "Installing asdf dependencies as defined in '$BUILDKITE_BUILD_CHECKOUT_PATH/.tool-versions':"
77
asdf install
8+
9+
asdf global kubectl 1.17.3
10+

.buildkite/verify-label.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cd "$(dirname "${BASH_SOURCE[0]}")/.."
66

77
.buildkite/install-yj.sh
88

9-
if find base -name "*.yaml" -exec sh -c "cat {} | yj | jq --raw-output '.metadata.labels.deploy'" \; | tee /tmp/deploy-label | grep -v sourcegraph; then
9+
if find base -name "*.yaml" \( ! -name kustomization.yaml \) -exec sh -c "cat {} | yj | jq --raw-output '.metadata.labels.deploy'" \; | tee /tmp/deploy-label | grep -v sourcegraph; then
1010
echo "> There exists a yaml file in base/ that does not contain .metadata.labels.deploy == sourcegraph"
1111
echo "> Run the following command to fix:"
1212
echo "find base/ -name \"*.yaml\" -exec sh -c \"cat {} | yj | jq '.metadata.labels.deploy = \\\"sourcegraph\\\"' | jy -o {}\" \;"

.buildkite/verify-yaml.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cd "$(dirname "${BASH_SOURCE[0]}")/.."
55

66
gcloud container clusters get-credentials dogfood --zone us-central1-a --project sourcegraph-dev
77

8-
kubectl apply --dry-run --validate --recursive -f base/ --context=gke_sourcegraph-dev_us-central1-a_dogfood
8+
kubectl apply --dry-run --validate -k base --context=gke_sourcegraph-dev_us-central1-a_dogfood
99
kubectl apply --dry-run --validate --recursive -f configure/ --context=gke_sourcegraph-dev_us-central1-a_dogfood
1010

1111
.buildkite/verify-label.sh

base/frontend/sourcegraph-frontend.Deployment.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ spec:
8282
volumeMounts:
8383
- mountPath: /mnt/cache
8484
name: cache-ssd
85-
securityContext:
86-
runAsUser: 0
8785
serviceAccountName: sourcegraph-frontend
8886
volumes:
8987
- emptyDir: {}

base/github-proxy/github-proxy.Deployment.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,3 @@ spec:
3838
requests:
3939
cpu: 100m
4040
memory: 250M
41-
securityContext:
42-
runAsUser: 0

base/gitserver/gitserver.StatefulSet.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ spec:
4545
volumeMounts:
4646
- mountPath: /data/repos
4747
name: repos
48+
securityContext:
49+
runAsUser: 100
50+
runAsGroup: 100
4851
# See the customization guide (../../../docs/configure.md) for information
4952
# about configuring gitserver to use an SSH key
5053
# - mountPath: /root/.ssh
5154
# name: ssh
5255
securityContext:
53-
runAsUser: 0
56+
fsGroup: 100
5457
volumes:
5558
- name: repos
5659
# See the customization guide (../../../docs/configure.md) for information

base/grafana/grafana.ClusterRole.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

base/grafana/grafana.ClusterRoleBinding.yaml

Lines changed: 0 additions & 16 deletions
This file was deleted.

base/grafana/grafana.Deployment.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@ spec:
4242
requests:
4343
cpu: 100m
4444
memory: 100Mi
45+
securityContext:
46+
runAsUser: 472
47+
runAsGroup: 472
4548
serviceAccountName: grafana
4649
securityContext:
47-
runAsUser: 0
50+
fsGroup: 472
4851
volumes:
4952
- name: data
5053
persistentVolumeClaim:

base/indexed-search/indexed-search.StatefulSet.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ spec:
4343
volumeMounts:
4444
- mountPath: /data
4545
name: data
46+
securityContext:
47+
runAsUser: 100
48+
runAsGroup: 100
4649
- env:
4750
image: index.docker.io/sourcegraph/zoekt-indexserver:0.0.20200221095506-2880d98@sha256:91643d83223bb72f4aa2b5031ceb774c8e604a227c58ed54375bd341f25e2ef3
4851
terminationMessagePolicy: FallbackToLogsOnError
@@ -62,8 +65,11 @@ spec:
6265
volumeMounts:
6366
- mountPath: /data
6467
name: data
68+
securityContext:
69+
runAsUser: 100
70+
runAsGroup: 100
6571
securityContext:
66-
runAsUser: 0
72+
fsGroup: 100
6773
volumes:
6874
- name: data
6975
updateStrategy:

0 commit comments

Comments
 (0)