mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-02-14 09:39:56 +00:00
♻️ 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:
@@ -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
42
k8s/tilt-registry.yaml
Normal 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
|
||||
@@ -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
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user