-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cluster: add registry mirrors for the cluster network (#51)
Fixes #49
- Loading branch information
Showing
17 changed files
with
226 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,49 @@ | ||
version: 2.1 | ||
orbs: | ||
slack: circleci/[email protected] | ||
kubernetes: circleci/[email protected] | ||
jobs: | ||
build: | ||
docker: | ||
- image: circleci/golang:1.14 | ||
working_directory: /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}} | ||
working_directory: /go/src/github.com/tilt-dev/ctlptl | ||
steps: | ||
- checkout | ||
- run: go get -v -t -d ./... | ||
- run: go test -v ./... | ||
- slack/notify-on-failure: | ||
only_for_branches: master | ||
|
||
e2e: | ||
machine: | ||
image: ubuntu-1604:201903-01 | ||
working_directory: /home/circleci/.go_workspace/src/github.com/tilt-dev/ctlptl | ||
steps: | ||
- checkout | ||
- kubernetes/install-kubectl | ||
- run: | | ||
set -ex | ||
wget https://golang.org/dl/go1.15.5.linux-amd64.tar.gz | ||
sudo rm -fR /usr/local/go | ||
sudo tar -C /usr/local -xzf go1.15.5.linux-amd64.tar.gz | ||
- run: | | ||
set -ex | ||
export MINIKUBE_VERSION=v1.15.0 | ||
curl -fLo ./minikube-linux-amd64 "https://github.com/kubernetes/minikube/releases/download/${MINIKUBE_VERSION}/minikube-linux-amd64" | ||
chmod +x ./minikube-linux-amd64 | ||
sudo mv ./minikube-linux-amd64 /usr/local/bin/minikube | ||
- run: | | ||
set -ex | ||
export KIND_VERSION=v0.9.0 | ||
curl -fLo ./kind-linux-amd64 "https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-linux-amd64" | ||
chmod +x ./kind-linux-amd64 | ||
sudo mv ./kind-linux-amd64 /usr/local/bin/kind | ||
- run: | | ||
set -ex | ||
go get -v -t -d ./... | ||
test/e2e.sh | ||
- slack/notify-on-failure: | ||
only_for_branches: master | ||
|
||
release-dry-run: | ||
docker: | ||
|
@@ -43,6 +75,10 @@ workflows: | |
jobs: | ||
- build: | ||
context: Tilt Slack Context | ||
- e2e: | ||
context: Tilt Slack Context | ||
requires: | ||
- build | ||
- release-dry-run: | ||
context: Tilt Slack Context | ||
requires: | ||
|
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 |
---|---|---|
|
@@ -11,3 +11,7 @@ generated: | |
|
||
tidy: | ||
go mod tidy | ||
|
||
e2e: | ||
test/e2e.sh | ||
|
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
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
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
# Integration tests that create a full cluster. | ||
|
||
set -exo pipefail | ||
|
||
cd $(dirname $(dirname $(realpath $0))) | ||
make install | ||
test/kind-cluster-network/e2e.sh | ||
test/minikube-cluster-network/e2e.sh |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM golang:1.15 | ||
RUN go get github.com/google/ko/cmd/ko | ||
WORKDIR /go/github.com/tilt-dev/ctlptl/test/cluster-network | ||
ADD . . |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: ko-builder | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
app: ko-builder | ||
spec: | ||
containers: | ||
- name: builder | ||
image: localhost:5005/ko-builder | ||
command: ["bash", "-c", | ||
"go get github.com/tilt-dev/ctlptl/test/simple-server && ko publish --insecure-registry github.com/tilt-dev/ctlptl/test/simple-server"] | ||
env: | ||
- name: KO_DOCKER_REPO | ||
value: REGISTRY_HOST_PLACEHOLDER | ||
- name: GO111MODULE | ||
value: "off" | ||
restartPolicy: Never | ||
backoffLimit: 4 |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: ctlptl.dev/v1alpha1 | ||
kind: Cluster | ||
name: kind-ctlptl-test-cluster | ||
product: kind | ||
registry: ctlptl-test-registry | ||
|
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
# Tests creating a cluster with a registry, | ||
# building a container in that cluster, | ||
# then running that container. | ||
|
||
set -exo pipefail | ||
|
||
cd $(dirname $(realpath $0)) | ||
ctlptl apply -f registry.yaml | ||
ctlptl apply -f cluster.yaml | ||
|
||
# The ko-builder runs in an image tagged with the host as visible from the local machine. | ||
docker build -t localhost:5005/ko-builder . | ||
docker push localhost:5005/ko-builder | ||
|
||
# The ko-builder builds an image tagged with the host as visible from the cluster network. | ||
HOST=$(ctlptl get cluster kind-ctlptl-test-cluster -o template --template '{{.status.localRegistryHosting.hostFromClusterNetwork}}') | ||
cat builder.yaml | sed "s/REGISTRY_HOST_PLACEHOLDER/$HOST/" | kubectl apply -f - | ||
kubectl wait --for=condition=complete job/ko-builder --timeout=180s | ||
cat simple-server.yaml | sed "s/REGISTRY_HOST_PLACEHOLDER/$HOST/" | kubectl apply -f - | ||
kubectl wait --for=condition=available deployment/simple-server --timeout=60s | ||
ctlptl delete -f cluster.yaml | ||
echo "kind-cluster-network test passed!" |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: ctlptl.dev/v1alpha1 | ||
kind: Registry | ||
name: ctlptl-test-registry | ||
port: 5005 |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: simple-server | ||
labels: | ||
app: simple-server | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: simple-server | ||
template: | ||
metadata: | ||
labels: | ||
app: simple-server | ||
spec: | ||
containers: | ||
- name: simple-server | ||
image: REGISTRY_HOST_PLACEHOLDER/simple-server-ee41f08d9609e718cc045a4f0190444b | ||
ports: | ||
- containerPort: 8080 | ||
livenessProbe: | ||
httpGet: | ||
path: / | ||
port: 8080 |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM golang:1.15 | ||
RUN go get github.com/google/ko/cmd/ko | ||
WORKDIR /go/github.com/tilt-dev/ctlptl/test/cluster-network | ||
ADD . . |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: ko-builder | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
app: ko-builder | ||
spec: | ||
containers: | ||
- name: builder | ||
image: localhost:5005/ko-builder | ||
command: ["bash", "-c", | ||
"go get github.com/tilt-dev/ctlptl/test/simple-server && ko publish --insecure-registry github.com/tilt-dev/ctlptl/test/simple-server"] | ||
env: | ||
- name: KO_DOCKER_REPO | ||
value: REGISTRY_HOST_PLACEHOLDER | ||
- name: GO111MODULE | ||
value: "off" | ||
restartPolicy: Never | ||
backoffLimit: 4 |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: ctlptl.dev/v1alpha1 | ||
kind: Cluster | ||
name: minikube-ctlptl-test-cluster | ||
product: minikube | ||
registry: ctlptl-test-registry | ||
|
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
# Tests creating a cluster with a registry, | ||
# building a container in that cluster, | ||
# then running that container. | ||
|
||
set -exo pipefail | ||
|
||
cd $(dirname $(realpath $0)) | ||
ctlptl apply -f registry.yaml | ||
ctlptl apply -f cluster.yaml | ||
|
||
# The ko-builder runs in an image tagged with the host as visible from the local machine. | ||
docker build -t localhost:5005/ko-builder . | ||
docker push localhost:5005/ko-builder | ||
|
||
# The ko-builder builds an image tagged with the host as visible from the cluster network. | ||
HOST=$(ctlptl get cluster minikube-ctlptl-test-cluster -o template --template '{{.status.localRegistryHosting.hostFromClusterNetwork}}') | ||
cat builder.yaml | sed "s/REGISTRY_HOST_PLACEHOLDER/$HOST/g" | kubectl apply -f - | ||
kubectl wait --for=condition=complete job/ko-builder --timeout=180s | ||
cat simple-server.yaml | sed "s/REGISTRY_HOST_PLACEHOLDER/$HOST/g" | kubectl apply -f - | ||
kubectl wait --for=condition=available deployment/simple-server --timeout=60s | ||
ctlptl delete -f cluster.yaml | ||
|
||
echo "minikube-cluster-network test passed!" |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: ctlptl.dev/v1alpha1 | ||
kind: Registry | ||
name: ctlptl-test-registry | ||
port: 5005 |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: simple-server | ||
labels: | ||
app: simple-server | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: simple-server | ||
template: | ||
metadata: | ||
labels: | ||
app: simple-server | ||
spec: | ||
containers: | ||
- name: simple-server | ||
image: REGISTRY_HOST_PLACEHOLDER/simple-server-ee41f08d9609e718cc045a4f0190444b | ||
ports: | ||
- containerPort: 8080 | ||
livenessProbe: | ||
httpGet: | ||
path: / | ||
port: 8080 |