Skip to content

Commit 9b8b5be

Browse files
authored
update outpdated k8s apis (#598)
1 parent 7008368 commit 9b8b5be

26 files changed

+150
-88
lines changed

.buildkite/cleanup-unused-disks.sh

+7-8
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@ set -euxo pipefail
66
SOURCEGRAPH_AUXILIARY_PROJECT=sourcegraph-server
77

88
gcloud_command() {
9-
gcloud --quiet --project="$SOURCEGRAPH_AUXILIARY_PROJECT" "$@"
9+
gcloud --quiet --project="$SOURCEGRAPH_AUXILIARY_PROJECT" "$@"
1010
}
1111

1212
echo "--- Deleting unattached GCP disks from the '$SOURCEGRAPH_AUXILIARY_PROJECT' project"
1313

1414
# See https://groups.google.com/d/msg/gce-discussion/RLrwOx8fazo/9ve7lIdsBQAJ for more information.
1515
unattached_disks=$(gcloud_command compute disks list --filter="-users:*" --format="value(selfLink)")
1616

17-
for disk in $unattached_disks
18-
do
19-
echo "Deleting disk: $disk"
20-
21-
# "gcloud compute disks delete ..." will never delete an attached disk.
22-
# See https://cloud.google.com/sdk/gcloud/reference/compute/disks/delete for more information.
23-
gcloud_command compute disks delete $disk
17+
for disk in $unattached_disks; do
18+
echo "Deleting disk: $disk"
19+
20+
# "gcloud compute disks delete ..." will never delete an attached disk.
21+
# See https://cloud.google.com/sdk/gcloud/reference/compute/disks/delete for more information.
22+
gcloud_command compute disks delete "$disk"
2423
done
2524

2625
echo "done"

.buildkite/hooks/pre-command

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
#!/usr/bin/env bash
22

33
set -eu
4-
pushd $(dirname "${BASH_SOURCE[0]}")/../..
4+
pushd "$(dirname "${BASH_SOURCE[0]}")"/../..
55

66
TOOL_VERSION_FILES=()
77
mapfile -d $'\0' TOOL_VERSION_FILES < <(fd .tool-versions --hidden --absolute-path --print0)
88

9-
for file in "${TOOL_VERSION_FILES[@]}"
10-
do
11-
echo "Installing asdf dependencies as defined in ${file}:"
12-
parent=$(dirname "${file}")
13-
pushd "${parent}"
14-
15-
asdf install
16-
17-
popd
9+
for file in "${TOOL_VERSION_FILES[@]}"; do
10+
echo "Installing asdf dependencies as defined in ${file}:"
11+
parent=$(dirname "${file}")
12+
pushd "${parent}"
13+
14+
asdf install
15+
16+
popd
1817
done
1918

2019
popd

.buildkite/install-yj.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
VERSION=1.0.0
44

5-
if [ ! $(which yj) ]; then
6-
echo "Installing yj to /usr/local/bin"
7-
wget https://github.com/sourcegraph/yj/releases/download/v${VERSION}/yj-${VERSION}-linux-amd64 -O /usr/local/bin/yj
8-
chmod a+x /usr/local/bin/yj
5+
if [ ! "$(which yj)" ]; then
6+
echo "Installing yj to /usr/local/bin"
7+
wget https://github.com/sourcegraph/yj/releases/download/v${VERSION}/yj-${VERSION}-linux-amd64 -O /usr/local/bin/yj
8+
chmod a+x /usr/local/bin/yj
99
fi

.buildkite/integration-restricted-test.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
set -ex
44

5-
cd $(dirname "${BASH_SOURCE[0]}")/..
5+
cd "$(dirname "${BASH_SOURCE[0]}")"/..
66

77
export TEST_GCP_PROJECT=sourcegraph-server
88
export TEST_GCP_ZONE=us-central1-a
99
export TEST_GCP_USERNAME=buildkite@sourcegraph-dev.iam.gserviceaccount.com
10-
export BUILD_CREATOR="$(echo $BUILDKITE_BUILD_CREATOR | tr ' @./' '_' | tr 'A-Z' 'a-z')"
10+
export BUILD_CREATOR="$(echo "$BUILDKITE_BUILD_CREATOR" | tr ' @./' '_' | tr 'A-Z' 'a-z')"
1111
export BUILD_UUID=$BUILDKITE_BUILD_ID
1212
export BUILD_BRANCH="$(echo $BUILDKITE_BRANCH | tr ' @./' '_' | tr 'A-Z' 'a-z')"
1313

1414
./tests/integration/restricted/test.sh
15-

.buildkite/integration-test.sh

+26-6
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,37 @@
22

33
set -ex
44

5-
cd $(dirname "${BASH_SOURCE[0]}")/..
5+
cd "$(dirname "${BASH_SOURCE[0]}")"/..
6+
7+
DEPLOY_SOURCEGRAPH_ROOT=$(pwd)
8+
export DEPLOY_SOURCEGRAPH_ROOT
69

7-
export DEPLOY_SOURCEGRAPH_ROOT=$(pwd)
810
export TEST_GCP_PROJECT=sourcegraph-server
911
export TEST_GCP_ZONE=us-central1-a
1012
export TEST_GCP_USERNAME=buildkite@sourcegraph-dev.iam.gserviceaccount.com
11-
export BUILD_CREATOR="$(echo $BUILDKITE_BUILD_CREATOR | tr ' /@.' '_' | tr 'A-Z' 'a-z')"
1213

13-
export GENERATED_BASE=`mktemp -d`
14+
BUILD_CREATOR="$(echo "${BUILDKITE_BUILD_CREATOR}" | tr ' /@.' '_' | tr '[:upper:]' '[:lower:]')"
15+
export BUILD_CREATOR
16+
17+
GENERATED_BASE=$(mktemp -d)
18+
export GENERATED_BASE
19+
20+
cleanup() {
21+
echo "--- Cleaning up test artifacts"
22+
rm -rf "${GENERATED_BASE}"
23+
}
24+
trap cleanup EXIT
25+
26+
kustomize build overlays/non-root-create-cluster -o "${GENERATED_BASE}"
27+
28+
TEST_ARGS=("test" "-timeout" "25m")
29+
30+
if [[ "${VERBOSE:-"false"}" == "true" ]]; then
31+
TEST_ARGS+=("-v")
32+
fi
1433

15-
kustomize build overlays/non-root-create-cluster -o ${GENERATED_BASE}
34+
TEST_ARGS+=("./...")
1635

17-
go test ./... -v -timeout 25m ${maybe_short_flag}
36+
echo "--- Running integration tests"
1837

38+
go "${TEST_ARGS[@]}"

.buildkite/pipeline.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ steps:
77
command: .buildkite/verify-rbac-labels.sh
88
- label: ':lipstick:'
99
command: .buildkite/prettier-check.sh
10+
- label: ':lipstick:'
11+
command: .buildkite/shfmt.sh
1012

1113
- wait
1214

1315
- label: ":pulumi: :k8s:"
14-
concurrency: 5
16+
concurrency: 3
1517
concurrency_group: deploy-sourcegraph/integration
1618
command: .buildkite/integration-test.sh
1719

.buildkite/prettier-check.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
cd $(dirname "${BASH_SOURCE[0]}")/..
44
set -euxo pipefail
55

6-
cd tests/integration/fresh/step1
6+
cd tests/integration/fresh/step1
77

88
yarn
99

10-
yarn run prettier-check
10+
yarn run prettier-check

.buildkite/shfmt.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
cd "$(dirname "${BASH_SOURCE[0]}")"/..
6+
7+
shfmt -d .

.buildkite/verify-label.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ cd "$(dirname "${BASH_SOURCE[0]}")/.."
77
.buildkite/install-yj.sh
88

99
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
10-
echo "> There exists a yaml file in base/ that does not contain .metadata.labels.deploy == sourcegraph"
11-
echo "> Run the following command to fix:"
12-
echo "find base/ -name \"*.yaml\" -exec sh -c \"cat {} | yj | jq '.metadata.labels.deploy = \\\"sourcegraph\\\"' | jy -o {}\" \;"
10+
echo "> There exists a yaml file in base/ that does not contain .metadata.labels.deploy == sourcegraph"
11+
echo "> Run the following command to fix:"
12+
echo "find base/ -name \"*.yaml\" -exec sh -c \"cat {} | yj | jq '.metadata.labels.deploy = \\\"sourcegraph\\\"' | jy -o {}\" \;"
1313

14-
exit 1
14+
exit 1
1515
fi

.buildkite/verify-rbac-labels.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ cd $(dirname "${BASH_SOURCE[0]}")/..
88
missing_labels=$(find base configure -not \( -path configure/ingress-nginx -prune \) -name "*.yaml" -print0 | xargs -0L1 -I {} sh -c "cat {} | yaml2json | jq -s --exit-status -f .buildkite/rbac.jq > /dev/null || echo {}")
99

1010
if [ ! -z "${missing_labels}" ]; then
11-
{
12-
echo "> Some files that declare RBAC-related resources are missing the 'category: rbac' label."
13-
echo "> The 'category: rbac' label allows users to filter out these resources when applying them to a K8s cluster if they lack sufficient permissions."
14-
echo "> Please add 'metadata.labels.category: rbac' to the following files:"
15-
echo "${missing_labels}"
16-
} 2> /dev/null
17-
exit 1
11+
{
12+
echo "> Some files that declare RBAC-related resources are missing the 'category: rbac' label."
13+
echo "> The 'category: rbac' label allows users to filter out these resources when applying them to a K8s cluster if they lack sufficient permissions."
14+
echo "> Please add 'metadata.labels.category: rbac' to the following files:"
15+
echo "${missing_labels}"
16+
} 2>/dev/null
17+
exit 1
1818
fi

.editorconfig

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[*.sh]
2+
indent_style = space
3+
indent_size = 2
4+
switch_case_indent = true

.tool-versions

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ kubectl 1.17.3
44
pulumi 1.12.0
55
fd 7.4.0
66
kustomize 3.5.4
7-
7+
shfmt 3.1.0

.vscode/extensions.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": [
5+
"EditorConfig.editorconfig",
6+
"esbenp.prettier-vscode",
7+
"ms-vscode.Go",
8+
"dbaeumer.vscode-eslint",
9+
"foxundermoon.shell-format",
10+
"timonwong.shellcheck"
11+
]
12+
}

.vscode/settings.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
"[yaml]": {
33
"editor.formatOnSave": false
4-
}
4+
},
5+
"[shellscript]": {
6+
"editor.defaultFormatter": "foxundermoon.shell-format",
7+
"editor.formatOnSave": true
8+
},
9+
"shellformat.flag": "-i 2 -ci"
510
}

base/frontend/sourcegraph-frontend.Ingress.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: extensions/v1beta1
1+
apiVersion: networking.k8s.io/v1beta1
22
kind: Ingress
33
metadata:
44
annotations:

base/jaeger/jaeger.Deployment.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: extensions/v1beta1
1+
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: jaeger
@@ -9,6 +9,11 @@ metadata:
99
app.kubernetes.io/component: all-in-one
1010
spec:
1111
replicas: 1
12+
selector:
13+
matchLabels:
14+
app: jaeger
15+
app.kubernetes.io/name: jaeger
16+
app.kubernetes.io/component: all-in-one
1217
strategy:
1318
type: Recreate
1419
template:

configure/lang/go/lang-go.Ingress.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: extensions/v1beta1
1+
apiVersion: networking.k8s.io/v1beta1
22
kind: Ingress
33
metadata:
44
name: lang-go

configure/lang/typescript/lang-typescript.Ingress.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: extensions/v1beta1
1+
apiVersion: networking.k8s.io/v1beta1
22
kind: Ingress
33
metadata:
44
name: lang-typescript

create-new-cluster.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
#!/bin/bash
22
#
33
# This file should be filled in by customers with the `kubectl` commands that should be run on
4-
# new cluster creation.
4+
# new cluster creation.
55
#
6-
# ./kubectl-apply-all.sh already runs all the `kubectl apply` commands
7-
# that applies your YAML files to the cluster. In addition, you should add commands
6+
# ./kubectl-apply-all.sh already runs all the `kubectl apply` commands
7+
# that applies your YAML files to the cluster. In addition, you should add commands
88
# to create Kubernetes objects which satisfy one of the following conditions:
99
#
1010
# * The object is a secret that shouldn't be committed to version control. (.e.g `kubectl create secret ...`)
1111
# * The object will never be updated after creation. (e.g., a network load balancer - `kubectl expose ...`)
1212
#
1313
# Objects that do not meet the above criteria should NOT be created by this script. Instead, create
14-
# a YAML file that can be `kubectl apply`d to the cluster, version that file in this repository, and add
14+
# a YAML file that can be `kubectl apply`d to the cluster, version that file in this repository, and add
1515
# the relevant `kubectl apply` command to ./kubectl-apply-all.sh
1616

1717
kubectl apply -l deploy=sourcegraph -k overlays/non-root-create-cluster

go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ go 1.14
44

55
require (
66
github.com/docker/docker v1.13.1 // indirect
7-
github.com/frankban/quicktest v1.4.2
87
github.com/pulumi/pulumi v1.12.0
98
github.com/sethgrid/pester v0.0.0-20190127155807-68a33a018ad0
109
)

go.sum

-2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjr
104104
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
105105
github.com/fortytw2/leaktest v1.2.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
106106
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
107-
github.com/frankban/quicktest v1.4.2 h1:eV8n2LQHuA97qKj0t6+7UrHRU0Smz9G+yh87F3Z+3Uk=
108-
github.com/frankban/quicktest v1.4.2/go.mod h1:36zfPVQyHxymz4cH7wlDmVwDrJuljRB60qkgn7rorfQ=
109107
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
110108
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
111109
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=

kubectl-apply-all.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
#
33
# This file should contain `kubectl apply` commands for all of your configured resources.
4-
#
4+
#
55
# This file should be run:
66
# * When the cluster is first created
77
# * Whenever the configuration for any resource has been updated
@@ -10,11 +10,11 @@
1010

1111
# Applies k8s resource files from first argument (a directory) using label specified as second argument.
1212
# Traverses first argument recursively collecting yaml files but avoiding kustomization.yaml files.
13-
apply () {
13+
apply() {
1414
local DIR=$1
1515
local LABEL=$2
1616

17-
local FILES=`find ${DIR} -name "*.yaml" \( ! -name kustomization.yaml \) | tr "\n" "," | sed 's/,$/ /' | tr " " "\n"`
17+
local FILES=$(find ${DIR} -name "*.yaml" \( ! -name kustomization.yaml \) | tr "\n" "," | sed 's/,$/ /' | tr " " "\n")
1818

1919
kubectl apply --prune -l ${LABEL} -f ${FILES}
2020
}

0 commit comments

Comments
 (0)