Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: adapt day 2 operations guide #2936

Merged
merged 15 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions docs/docs/use-cases/assets/app-updated-version.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions docs/docs/use-cases/assets/app-with-new-workload.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
apiVersion: v1
kind: Namespace
metadata:
name: podtato-kubectl
annotations:
keptn.sh/lifecycle-toolkit: "enabled"

bacherfl marked this conversation as resolved.
Show resolved Hide resolved
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: podtato-head-frontend
namespace: podtato-kubectl
spec:
selector:
matchLabels:
app.kubernetes.io/name: podtato-head-frontend
template:
metadata:
labels:
app.kubernetes.io/name: podtato-head-frontend
app.kubernetes.io/part-of: podtato-head
app.kubernetes.io/version: 0.3.0
keptn.sh/pre-deployment-tasks: pre-deployment-check
spec:
containers:
- name: podtato-head-frontend
image: ghcr.io/podtato-head/podtato-server:v0.3.0
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: podtato-head-hat
namespace: podtato-kubectl
spec:
selector:
matchLabels:
app.kubernetes.io/name: podtato-head-hat
replicas: 1
template:
metadata:
labels:
app.kubernetes.io/name: podtato-head-hat
app.kubernetes.io/part-of: podtato-head
app.kubernetes.io/version: 0.3.0
spec:
containers:
- name: podtato-head-hat
image: ghcr.io/podtato-head/podtato-server:v0.3.0
---
apiVersion: lifecycle.keptn.sh/v1beta1
kind: KeptnTaskDefinition
metadata:
name: pre-deployment-check
namespace: podtato-kubectl
spec:
function:
inline:
code: |
console.log("Success")
---
---
bacherfl marked this conversation as resolved.
Show resolved Hide resolved
apiVersion: lifecycle.keptn.sh/v1beta1
kind: KeptnAppContext
metadata:
name: podtato-head
namespace: podtato-kubectl
spec:
preDeploymentTasks:
- pre-deployment-check
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ metadata:
name: podtato-head-frontend
namespace: podtato-kubectl
spec:
selector:
matchLabels:
app.kubernetes.io/name: podtato-head-frontend
template:
metadata:
labels:
app.kubernetes.io/name: podtato-head-frontend
app.kubernetes.io/part-of: podtato-head
app.kubernetes.io/version: 0.2.0 # The version label is now updated as well
keptn.sh/pre-deployment-evaluations: my-evaluation
keptn.sh/pre-deployment-tasks: my-task
app.kubernetes.io/version: 0.3.1 # The version label is now updated as well
keptn.sh/pre-deployment-tasks: pre-deployment-check
spec:
containers:
- name: podtato-head-frontend
image: podtato-head-frontend:b # The image tag has been updated from 'a' to 'b'
image: ghcr.io/podtato-head/podtato-server:v0.3.1 # The image tag has been updated from 'a' to 'b'
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: podtato-head-frontend
namespace: podtato-kubectl
spec:
selector:
matchLabels:
app.kubernetes.io/name: podtato-head-frontend
template:
metadata:
labels:
app.kubernetes.io/name: podtato-head-frontend
app.kubernetes.io/part-of: podtato-head
app.kubernetes.io/version: 0.3.0 # the version number stays the same
keptn.sh/pre-deployment-tasks: pre-deployment-check
spec:
containers:
- name: podtato-head-frontend
image: ghcr.io/podtato-head/podtato-server:v0.3.1 # the image tag has been updated to v0.3.1
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ metadata:
name: podtato-head-left-leg
namespace: podtato-kubectl
spec:
selector:
matchLabels:
app.kubernetes.io/name: podtato-head-left-leg
template:
metadata:
labels:
app.kubernetes.io/name: podtato-head-left-leg
app.kubernetes.io/part-of: podtato-head
app.kubernetes.io/version: 0.1.0
app.kubernetes.io/version: 0.3.0
spec:
containers:
- name: podtato-head-frontend
image: podtato-head-left-leg:a
- name: podtato-head-left-leg
image: ghcr.io/podtato-head/podtato-server:v0.3.1
44 changes: 0 additions & 44 deletions docs/docs/use-cases/assets/deployment-initial.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions docs/docs/use-cases/assets/deployment-new-image.yaml

This file was deleted.

71 changes: 24 additions & 47 deletions docs/docs/use-cases/day-2-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ completed for the version set in the labels/annotations.

To illustrate the update of a [workload](https://kubernetes.io/docs/concepts/workloads/),
let's assume the following example, including
a [workload](https://kubernetes.io/docs/concepts/workloads/) called `podtato-head-frontend` that includes a pre-task and
a pre-evaluation.
a [workload](https://kubernetes.io/docs/concepts/workloads/) called `podtato-head-frontend` that includes a
bacherfl marked this conversation as resolved.
Show resolved Hide resolved
pre-deployment task.

```yaml
{% include "./assets/deployment-initial.yaml" %}
{% include "./assets/day-2-operations/deployment-initial.yaml" %}
```

Now, let's assume that the configuration of that [workload](https://kubernetes.io/docs/concepts/workloads/) needs to be changed.
Now, let's assume that the configuration of that [workload](https://kubernetes.io/docs/concepts/workloads/)
needs to be changed.
In this example we assume that the image of that [workload](https://kubernetes.io/docs/concepts/workloads/)
should be updated, but a configuration change is not limited to that.
From here, you essentially have two options:
Expand All @@ -62,7 +63,7 @@ and the image must be updated as quickly as possible.
To do that, change `podtato-head-frontend` as follows:

```yaml
{% include "./assets/deployment-new-image.yaml" %}
{% include "./assets/day-2-operations/deployment-new-image.yaml" %}
bacherfl marked this conversation as resolved.
Show resolved Hide resolved
```

* **Update the configuration *and* the version label:**
Expand All @@ -73,28 +74,14 @@ are executed before the updated pods are scheduled.
In this case, the deployment should be changed as follows:

```yaml
{% include "./assets/deployment-new-image-and-version.yaml" %}
{% include "./assets/day-2-operations/deployment-new-image-and-version.yaml" %}
bacherfl marked this conversation as resolved.
Show resolved Hide resolved
```

If you have defined the related `KeptnApp` resource yourself,
this must also be updated to refer to the updated `KeptnWorkload`.
This is a mandatory step, since the `KeptnWorkload` associated with
this updated deployment is not able to progress otherwise.
Therefore, make sure that the version of `podtato-head-frontend`
is updated accordingly:

```yaml
{% include "./assets/app-updated-version.yaml" %}
```

Updating the `KeptnApp` also causes all pre-/post-tasks/evaluations
of the `KeptnApp` to be executed again.
In this example, this means that the tasks `wait-for-prometheus`,
and `post-deployment-loadtests` will run again.

If you are using the [automatic app discovery](../guides/auto-app-discovery.md),
you do not need to update the `KeptnApp` resource.
Keptn will take care of that for you.
Applying this causes the `KeptnApp` to be updated with a new
bacherfl marked this conversation as resolved.
Show resolved Hide resolved
version, and a new `KeptnAppVersion` to be created.
bacherfl marked this conversation as resolved.
Show resolved Hide resolved
Due to this, all checks defined in the `KeptnAppContext`,
bacherfl marked this conversation as resolved.
Show resolved Hide resolved
as well as those defined in the deployment's `keptn.sh/pre-deployment-tasks`
label are executed again.

After applying the updated manifests, you can monitor the status
of the application and related [workloads](https://kubernetes.io/docs/concepts/workloads/) using the following commands:
Expand All @@ -103,9 +90,9 @@ of the application and related [workloads](https://kubernetes.io/docs/concepts/w
$ kubectl get keptnworkloadversion -n podtato-kubectl

NAMESPACE NAME APPNAME WORKLOADNAME WORKLOADVERSION PHASE
podtato-kubectl podtato-head-podtato-head-frontend-0.1.0 podtato-head podtato-head-podtato-head-frontend 0.1.0 Completed
podtato-kubectl podtato-head-podtato-head-hat-0.1.1 podtato-head podtato-head-podtato-head-hat 0.1.1 Completed
podtato-kubectl podtato-head-podtato-head-frontend-0.2.0 podtato-head podtato-head-podtato-head-frontend 0.2.0 Completed
podtato-kubectl podtato-head-podtato-head-frontend-0.3.0 podtato-head podtato-head-podtato-head-frontend 0.3.0 Completed
podtato-kubectl podtato-head-podtato-head-hat-0.3.0 podtato-head podtato-head-podtato-head-hat 0.3.0 Completed
podtato-kubectl podtato-head-podtato-head-frontend-0.3.1 podtato-head podtato-head-podtato-head-frontend 0.3.1 Completed
```

As can be seen in the output of the command, the `KeptnWorkloadVersions` from the previous deployment
bacherfl marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -120,9 +107,9 @@ returning a newly created `KeptnAppVersion`.
```shell
$ kubectl get keptnappversion -n podtato-kubectl

NAMESPACE NAME APPNAME VERSION PHASE
podtato-kubectl podtato-head-0.1.0-6bch3iak podtato-head 0.1.0 Completed
podtato-kubectl podtato-head-0.1.0-hf52kauz podtato-head 0.1.0 Completed
NAMESPACE NAME APPNAME VERSION PHASE
podtato-kubectl podtato-head-f13dcb00ea-6b86b273 podtato-head 0.1.0 Completed
podtato-kubectl podtato-head-1c40c739cf-d4735e3a podtato-head 0.1.0 Completed
```

## Adding a new Workload to an Application
Expand All @@ -142,18 +129,7 @@ For example, to add the deployment `podtato-head-left-leg` to the
would look like this, with the required label being set:

```yaml
{% include "./assets/new-deployment.yaml" %}
```

The `KeptnApp`, if defined by the user, should contain the
reference to the newly added [workload](https://kubernetes.io/docs/concepts/workloads/).
This is mandatory, as the [workload](https://kubernetes.io/docs/concepts/workloads/) itself is not able to
progress if it is not part of a `KeptnApp`.
For automatically discovered apps this is done
automatically.

```yaml
{% include "./assets/app-with-new-workload.yaml" %}
{% include "./assets/day-2-operations/new-deployment.yaml" %}
```

After applying the updated manifests, you can monitor the status
Expand All @@ -163,12 +139,13 @@ of the application and related [workloads](https://kubernetes.io/docs/concepts/w
$ kubectl get keptnworkloadversion -n podtato-kubectl

NAMESPACE NAME APPNAME WORKLOADNAME WORKLOADVERSION PHASE
podtato-kubectl podtato-head-podtato-head-frontend-0.1.0 podtato-head podtato-head-podtato-head-frontend 0.1.0 Completed
podtato-kubectl podtato-head-podtato-head-hat-0.1.1 podtato-head podtato-head-podtato-head-hat 0.1.1 Completed
podtato-kubectl podtato-head-podtato-head-left-leg-0.1.0 podtato-head podtato-head-podtato-head-left-leg 0.1.0 Completed
podtato-kubectl podtato-head-podtato-head-frontend-0.3.0 podtato-head podtato-head-podtato-head-frontend 0.3.0 Completed
podtato-kubectl podtato-head-podtato-head-frontend-0.3.1 podtato-head podtato-head-podtato-head-frontend 0.3.1 Completed
podtato-kubectl podtato-head-podtato-head-hat-0.3.0 podtato-head podtato-head-podtato-head-hat 0.3.0 Completed
podtato-kubectl podtato-head-podtato-head-left-leg-0.3.0 podtato-head podtato-head-podtato-head-left-leg 0.3.0 Completed
```

As can be seen in the output of the command, in addition
to the previous `KeptnWorkloadVersions`, the newly created
`KeptnWorkloadVersion`, `podtato-head-podtato-head-left-leg-0.1.0` has been added
`KeptnWorkloadVersion`, `podtato-head-podtato-head-left-leg-0.3.0` has been added
to the results.
Loading