♻️ Improve Tilt section

Split out the Tilt registry to separate YAML files.
Expand the Tilt section a bit to clarify what happens
when running on cluster-that-don't-look-like-dev-ones.
This commit is contained in:
Jérôme Petazzoni
2021-09-29 19:17:43 +02:00
parent c5cd84e274
commit b7dd363ccd
3 changed files with 89 additions and 42 deletions

View File

@@ -1,39 +1,4 @@
k8s_yaml(blob('''
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: registry
name: registry
spec:
selector:
matchLabels:
app: registry
template:
metadata:
labels:
app: registry
spec:
containers:
- image: registry
name: registry
---
apiVersion: v1
kind: Service
metadata:
labels:
app: registry
name: registry
spec:
ports:
- port: 5000
protocol: TCP
targetPort: 5000
nodePort: 30555
selector:
app: registry
type: NodePort
'''))
k8s_yaml('../k8s/tilt-registry.yaml')
default_registry('localhost:30555')
docker_build('dockercoins/hasher', 'hasher')
docker_build('dockercoins/rng', 'rng')

42
k8s/tilt-registry.yaml Normal file
View File

@@ -0,0 +1,42 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: tilt-registry
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: tilt-registry
name: tilt-registry
namespace: tilt-registry
spec:
selector:
matchLabels:
app: tilt-registry
template:
metadata:
labels:
app: tilt-registry
spec:
containers:
- image: registry
name: registry
---
apiVersion: v1
kind: Service
metadata:
labels:
app: tilt-registry
name: tilt-registry
namespace: tilt-registry
spec:
ports:
- port: 5000
protocol: TCP
targetPort: 5000
nodePort: 30555
selector:
app: tilt-registry
type: NodePort

View File

@@ -181,17 +181,57 @@ Ah, right ...
- The `dockercoins` directory in our repository has a `Tiltfile`
- Go to that directory and try `tilt up`
- That Tiltfile includes definitions for the DockerCoins app, including:
- Tilt should refuse to start, but it will explain why
- building the images for the app
- Edit the `Tiltfile` accordingly and try again
- Kubernetes manifests to deploy the app
- Open the Tilt web UI
- a self-hosted registry to host the app image
(if running Tilt on a remote machine, you will need `tilt up --host 0.0.0.0`)
- Let's try it out!
- Watch as the Dockercoins app is built, pushed, started
---
## Running Tilt
- If you're running on your local machine:
```bash
tilt up
```
Then press "space" or connect to http://localhost:10350/
- If you're running on a remote machine:
```bash
tilt up --host=0.0.0.0
```
Then connect to the remote machine on port 10350
- The Tilt web interface might complain about the Kubernetes context
...If it does, don't worry, we'll fix that right away!
---
## Kubernetes contexts
- Tilt is designed to run in dev environments
- It will try to figure out if we're really in a dev environment:
- if Tilt thinks that are on a local dev cluster, it will start
- otherwise, it will give us a warning and it won't continue
- In the latter case, we need to add one line to the Tiltfile
(to tell Tilt "it's okay, you can run safely in this environment!")
- If this happens, add the line to the Tiltfile
(Tilt will tell you exactly what to add!)
- We don't need to restart Tilt, it will detect the change immediately
---