-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(operator): add fallback behavior when no keptn annotations are s…
…et (#171)
- Loading branch information
Showing
11 changed files
with
468 additions
and
16 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
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 @@ | ||
/slack-secret.yaml |
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,5 @@ | ||
### Create Secret for Slack here | ||
|
||
``` | ||
kubectl create secret generic slack-notification --from-literal=SECURE_DATA='{"slack_hook":"<WebHook>","text":"Deployed PodTatoHead Application"}' -n podtato-kubectl -oyaml --dry-run > slack-secret.yaml | ||
``` |
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: lifecycle.keptn.sh/v1alpha1 | ||
kind: KeptnApp | ||
metadata: | ||
name: podtato-head | ||
namespace: podtato-kubectl | ||
spec: | ||
version: "1.3" | ||
workloads: | ||
- name: podtato-head-left-arm | ||
version: 0.2.7 | ||
- name: podtato-head-left-leg | ||
version: 0.2.7 | ||
- name: podtato-head-entry | ||
version: 0.2.7 | ||
- name: podtato-head-right-arm | ||
version: 0.1.0 | ||
- name: podtato-head-left-arm | ||
version: 0.2.7 | ||
- name: podtato-head-hat | ||
version: 0.1.0 | ||
postDeploymentTasks: | ||
- post-deployment-hello |
12 changes: 12 additions & 0 deletions
12
examples/podtatohead-deployment-k8s-labels/check_entry.yaml
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,12 @@ | ||
apiVersion: lifecycle.keptn.sh/v1alpha1 | ||
kind: KeptnTaskDefinition | ||
metadata: | ||
name: check-entry-service | ||
namespace: podtato-kubectl | ||
spec: | ||
function: | ||
httpRef: | ||
url: https://raw.githubusercontent.com/keptn-sandbox/lifecycle-controller/main/functions-runtime/samples/ts/http.ts | ||
parameters: | ||
map: | ||
url: http://podtato-head-entry.podtato-kubectl.svc.cluster.local:9000 |
299 changes: 299 additions & 0 deletions
299
examples/podtatohead-deployment-k8s-labels/manifest.yaml
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,299 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: podtato-kubectl | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: podtato-head-entry | ||
namespace: podtato-kubectl | ||
labels: | ||
app: podtato-head | ||
spec: | ||
selector: | ||
matchLabels: | ||
component: podtato-head-entry | ||
template: | ||
metadata: | ||
labels: | ||
component: podtato-head-entry | ||
keptn.sh/app: podtato-head | ||
keptn.sh/workload: podtato-head-entry | ||
spec: | ||
terminationGracePeriodSeconds: 5 | ||
initContainers: | ||
- name: init-myservice | ||
image: busybox:1.28 | ||
command: ['sh', '-c', 'sleep 30'] | ||
containers: | ||
- name: server | ||
image: ghcr.io/podtato-head/entry:0.2.7 | ||
imagePullPolicy: Always | ||
ports: | ||
- containerPort: 9000 | ||
env: | ||
- name: PODTATO_PORT | ||
value: "9000" | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: podtato-head-entry | ||
namespace: podtato-kubectl | ||
labels: | ||
app: podtato-head | ||
spec: | ||
selector: | ||
component: podtato-head-entry | ||
ports: | ||
- name: http | ||
port: 9000 | ||
protocol: TCP | ||
targetPort: 9000 | ||
type: LoadBalancer | ||
# change to NodePort if no LoadBalancer controller is available | ||
# type: NodePort | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: podtato-head-hat | ||
namespace: podtato-kubectl | ||
labels: | ||
app: podtato-head | ||
spec: | ||
selector: | ||
matchLabels: | ||
component: podtato-head-hat | ||
template: | ||
metadata: | ||
labels: | ||
component: podtato-head-hat | ||
app.kubernetes.io/version: 0.1.0 | ||
annotations: | ||
app.kubernetes.io/part-of: podtato-head | ||
app.kubernetes.io/name: podtato-head-hat | ||
keptn.sh/pre-deployment-tasks: check-entry-service | ||
spec: | ||
terminationGracePeriodSeconds: 5 | ||
containers: | ||
- name: server | ||
image: ghcr.io/podtato-head/hat:0.2.7 | ||
imagePullPolicy: Always | ||
ports: | ||
- containerPort: 9000 | ||
env: | ||
- name: PODTATO_PORT | ||
value: "9000" | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: podtato-head-hat | ||
namespace: podtato-kubectl | ||
labels: | ||
app: podtato-head | ||
spec: | ||
selector: | ||
component: podtato-head-hat | ||
ports: | ||
- name: http | ||
port: 9001 | ||
protocol: TCP | ||
targetPort: 9000 | ||
type: ClusterIP | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: podtato-head-left-leg | ||
namespace: podtato-kubectl | ||
labels: | ||
app: podtato-head | ||
spec: | ||
selector: | ||
matchLabels: | ||
component: podtato-head-left-leg | ||
template: | ||
metadata: | ||
labels: | ||
component: podtato-head-left-leg | ||
annotations: | ||
app.kubernetes.io/part-of: podtato-head | ||
app.kubernetes.io/name: podtato-head-left-leg | ||
keptn.sh/pre-deployment-tasks: check-entry-service | ||
spec: | ||
terminationGracePeriodSeconds: 5 | ||
containers: | ||
- name: server | ||
image: ghcr.io/podtato-head/left-leg:0.2.7 | ||
imagePullPolicy: Always | ||
ports: | ||
- containerPort: 9000 | ||
env: | ||
- name: PODTATO_PORT | ||
value: "9000" | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: podtato-head-left-leg | ||
namespace: podtato-kubectl | ||
labels: | ||
app: podtato-head | ||
spec: | ||
selector: | ||
component: podtato-head-left-leg | ||
ports: | ||
- name: http | ||
port: 9002 | ||
protocol: TCP | ||
targetPort: 9000 | ||
type: ClusterIP | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: podtato-head-left-arm | ||
namespace: podtato-kubectl | ||
labels: | ||
app: podtato-head | ||
spec: | ||
selector: | ||
matchLabels: | ||
component: podtato-head-left-arm | ||
template: | ||
metadata: | ||
labels: | ||
component: podtato-head-left-arm | ||
app.kubernetes.io/part-of: podtato-head | ||
annotations: | ||
app.kubernetes.io/name: podtato-head-left-arm | ||
keptn.sh/pre-deployment-tasks: check-entry-service | ||
spec: | ||
terminationGracePeriodSeconds: 5 | ||
containers: | ||
- name: server | ||
image: ghcr.io/podtato-head/left-arm:0.2.7 | ||
imagePullPolicy: Always | ||
ports: | ||
- containerPort: 9000 | ||
env: | ||
- name: PODTATO_PORT | ||
value: "9000" | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: podtato-head-left-arm | ||
namespace: podtato-kubectl | ||
labels: | ||
app: podtato-head | ||
spec: | ||
selector: | ||
component: podtato-head-left-arm | ||
ports: | ||
- name: http | ||
port: 9003 | ||
protocol: TCP | ||
targetPort: 9000 | ||
type: ClusterIP | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: podtato-head-right-leg | ||
namespace: podtato-kubectl | ||
labels: | ||
app: podtato-head | ||
spec: | ||
selector: | ||
matchLabels: | ||
component: podtato-head-right-leg | ||
template: | ||
metadata: | ||
labels: | ||
component: podtato-head-right-leg | ||
annotations: | ||
app.kubernetes.io/part-of: podtato-head | ||
app.kubernetes.io/name: podtato-head-right-leg | ||
keptn.sh/pre-deployment-tasks: check-entry-service | ||
spec: | ||
terminationGracePeriodSeconds: 5 | ||
containers: | ||
- name: server | ||
image: ghcr.io/podtato-head/right-leg:0.2.7 | ||
imagePullPolicy: Always | ||
ports: | ||
- containerPort: 9000 | ||
env: | ||
- name: PODTATO_PORT | ||
value: "9000" | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: podtato-head-right-leg | ||
namespace: podtato-kubectl | ||
labels: | ||
app: podtato-head | ||
spec: | ||
selector: | ||
component: podtato-head-right-leg | ||
ports: | ||
- name: http | ||
port: 9004 | ||
protocol: TCP | ||
targetPort: 9000 | ||
type: ClusterIP | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: podtato-head-right-arm | ||
namespace: podtato-kubectl | ||
labels: | ||
app: podtato-head | ||
spec: | ||
selector: | ||
matchLabels: | ||
component: podtato-head-right-arm | ||
template: | ||
metadata: | ||
labels: | ||
component: podtato-head-right-arm | ||
annotations: | ||
app.kubernetes.io/part-of: podtato-head | ||
keptn.sh/workload: podtato-head-right-arm | ||
keptn.sh/version: 0.1.0 | ||
keptn.sh/pre-deployment-tasks: check-entry-service | ||
spec: | ||
terminationGracePeriodSeconds: 5 | ||
containers: | ||
- name: server | ||
image: ghcr.io/podtato-head/right-arm:0.2.7 | ||
imagePullPolicy: Always | ||
ports: | ||
- containerPort: 9000 | ||
env: | ||
- name: PODTATO_PORT | ||
value: "9000" | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: podtato-head-right-arm | ||
namespace: podtato-kubectl | ||
labels: | ||
app: podtato-head | ||
spec: | ||
selector: | ||
component: podtato-head-right-arm | ||
ports: | ||
- name: http | ||
port: 9005 | ||
protocol: TCP | ||
targetPort: 9000 | ||
type: ClusterIP |
25 changes: 25 additions & 0 deletions
25
examples/podtatohead-deployment-k8s-labels/post-deployment-tasks.yaml
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,25 @@ | ||
apiVersion: lifecycle.keptn.sh/v1alpha1 | ||
kind: KeptnTaskDefinition | ||
metadata: | ||
name: post-deployment-hello | ||
namespace: podtato-kubectl | ||
spec: | ||
function: | ||
inline: | ||
code: | | ||
let text = Deno.env.get("SECURE_DATA"); | ||
let data; | ||
if (text != undefined) { | ||
data = JSON.parse(text); | ||
} | ||
const body = `{"text": "${data.text}"}`; | ||
console.log(body) | ||
let resp = await fetch("https://hooks.slack.com/services/" + data.slack_hook, { | ||
method: "POST", | ||
body, | ||
}); | ||
console.log(resp) | ||
secureParameters: | ||
secret: slack-notification |
Oops, something went wrong.