forked from BretFisher/kubernetes-mastery
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cronjobs and YAML catch up instructions
- Loading branch information
Showing
6 changed files
with
337 additions
and
15 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 |
---|---|---|
@@ -0,0 +1,160 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: hasher | ||
name: hasher | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: hasher | ||
template: | ||
metadata: | ||
labels: | ||
app: hasher | ||
spec: | ||
containers: | ||
- image: dockercoins/hasher:v0.1 | ||
name: hasher | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app: hasher | ||
name: hasher | ||
spec: | ||
ports: | ||
- port: 80 | ||
protocol: TCP | ||
targetPort: 80 | ||
selector: | ||
app: hasher | ||
type: ClusterIP | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: redis | ||
name: redis | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: redis | ||
template: | ||
metadata: | ||
labels: | ||
app: redis | ||
spec: | ||
containers: | ||
- image: redis | ||
name: redis | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app: redis | ||
name: redis | ||
spec: | ||
ports: | ||
- port: 6379 | ||
protocol: TCP | ||
targetPort: 6379 | ||
selector: | ||
app: redis | ||
type: ClusterIP | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: rng | ||
name: rng | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: rng | ||
template: | ||
metadata: | ||
labels: | ||
app: rng | ||
spec: | ||
containers: | ||
- image: dockercoins/rng:v0.1 | ||
name: rng | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app: rng | ||
name: rng | ||
spec: | ||
ports: | ||
- port: 80 | ||
protocol: TCP | ||
targetPort: 80 | ||
selector: | ||
app: rng | ||
type: ClusterIP | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: webui | ||
name: webui | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: webui | ||
template: | ||
metadata: | ||
labels: | ||
app: webui | ||
spec: | ||
containers: | ||
- image: dockercoins/webui:v0.1 | ||
name: webui | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app: webui | ||
name: webui | ||
spec: | ||
ports: | ||
- port: 80 | ||
protocol: TCP | ||
targetPort: 80 | ||
selector: | ||
app: webui | ||
type: NodePort | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: worker | ||
name: worker | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: worker | ||
template: | ||
metadata: | ||
labels: | ||
app: worker | ||
spec: | ||
containers: | ||
- image: dockercoins/worker:v0.1 | ||
name: worker |
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,93 @@ | ||
# Deploying with YAML | ||
|
||
- So far, we created resources with the following commands: | ||
|
||
- `kubectl run` | ||
|
||
- `kubectl create deployment` | ||
|
||
- `kubectl expose` | ||
|
||
- We can also create resources directly with YAML manifests | ||
|
||
--- | ||
|
||
## `kubectl apply` vs `create` | ||
|
||
- `kubectl create -f whatever.yaml` | ||
|
||
- creates resources if they don't exist | ||
|
||
- if resources already exist, don't alter them | ||
<br/>(and display error message) | ||
|
||
- `kubectl apply -f whatever.yaml` | ||
|
||
- creates resources if they don't exist | ||
|
||
- if resources already exist, update them | ||
<br/>(to match the definition provided by the YAML file) | ||
|
||
- stores the manifest as an *annotation* in the resource | ||
|
||
--- | ||
|
||
## Creating multiple resources | ||
|
||
- The manifest can contain multiple resources separated by `---` | ||
|
||
```yaml | ||
kind: ... | ||
apiVersion: ... | ||
metadata: ... | ||
name: ... | ||
... | ||
--- | ||
kind: ... | ||
apiVersion: ... | ||
metadata: ... | ||
name: ... | ||
... | ||
``` | ||
|
||
--- | ||
|
||
## Creating multiple resources | ||
|
||
- The manifest can also contain a list of resources | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: List | ||
items: | ||
- kind: ... | ||
apiVersion: ... | ||
... | ||
- kind: ... | ||
apiVersion: ... | ||
... | ||
``` | ||
|
||
--- | ||
|
||
## Deploying dockercoins with YAML | ||
|
||
- We provide a YAML manifest with all the resources for Dockercoins | ||
|
||
(Deployments and Services) | ||
|
||
- We can use it if we need to deploy or redeploy Dockercoins | ||
|
||
.exercise[ | ||
|
||
- Deploy or redeploy Dockercoins: | ||
```bash | ||
kubectl apply -f ~/container.training/k8s/dockercoins.yaml | ||
``` | ||
|
||
] | ||
|
||
(If we deployed Dockercoins earlier, we will see warning messages, | ||
because the resources that we created lack the necessary annotation. | ||
We can safely ignore them.) | ||
|
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
Oops, something went wrong.