Skip to content

Commit

Permalink
fix: Fixed problems in examples (#378)
Browse files Browse the repository at this point in the history
Signed-off-by: odubajDT <[email protected]>
Signed-off-by: odubajDT <[email protected]>
Co-authored-by: Thomas Schuetz <[email protected]>
  • Loading branch information
odubajDT and thschue authored Nov 11, 2022
1 parent 58161a1 commit 277be10
Show file tree
Hide file tree
Showing 17 changed files with 94 additions and 35 deletions.
8 changes: 8 additions & 0 deletions examples/argo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ ARGO_SECRET = $(shell kubectl -n ${ARGO_NAMESPACE} get secret argocd-initial-adm

.PHONY: install
install:
@echo "-----------------------------------"
@echo "Create Namespace and install Keptn-lifecycle-toolkit"
@echo "-----------------------------------"
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.10.0/cert-manager.yaml
kubectl wait --for=condition=available deployment/cert-manager -n cert-manager --timeout=300s
kubectl apply -f https://github.com/keptn/lifecycle-toolkit/releases/download/v0.4.0/manifest.yaml #x-release-please-version
kubectl wait --for=condition=available deployment/klc-controller-manager -n keptn-lifecycle-toolkit-system --timeout=300s

@echo "-----------------------------------"
@echo "Create Namespace and install ArgoCD"
@echo "-----------------------------------"
Expand Down
9 changes: 5 additions & 4 deletions examples/argo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
In this example, we will show you how to install our sample application *podtatohead* using the Keptn Lifecycle Controller and [ArgoCD](https://argo-cd.readthedocs.io/en/stable/).

# TL;DR
* You can install ArgoCD using: `make install`
* You can install ArgoCD and Keptn-lifecycle-toolkit using: `make install`
* Install argo CLI according to the instructions [here](https://argo-cd.readthedocs.io/en/stable/cli_installation/)
* Afterward, you can fetch the secret for the ArgoCD CLI using: `make argo-get-password`
* Then you can port-forward the ArgoUI using: `make argo-port-forward`
* Then you can port-forward the ArgoUI using: `make port-forward-argocd`
* Alternatively, you can access Argo using the CLI, configure it using `make argo-configure-cli`
* Deploy the PodTatoHead Demo Application: `make argo-install-podtatohead`
* Watch the progress on your ArgoUI: `http://localhost:8080`
* Watch the progress on your ArgoUI: `http://localhost:8080`. Use the `admin` user and the password from `make argo-get-password`.

## Prerequisites:
This tutorial assumes, that you already installed the Keptn Lifecycle Controller (see https://github.com/keptn/lifecycle-toolkit). Furthermore, you have to install ArgoCD, as in the following their [installation instructions](https://argo-cd.readthedocs.io/en/stable/getting_started/).
This tutorial assumes, that you already installed the Keptn Lifecycle Controller (see https://github.com/keptn/lifecycle-toolkit). The installation instructions can be found [here](https://github.com/keptn/lifecycle-toolkit#deploy-the-latest-release). Furthermore, you have to install ArgoCD, as in the following their [installation instructions](https://argo-cd.readthedocs.io/en/stable/getting_started/).

### Install ArgoCD
If you don't have an already existing installation of ArgoCD, you can [install](https://raw.githubusercontent.com/argoproj/argo-cd/v2.4.14/manifests/install.yaml) it using the following commands:
Expand Down
3 changes: 2 additions & 1 deletion examples/kubecon-na-22-demo/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
JAEGER_VERSION ?= v1.38.0
LFC_NAMESPACE ?= keptn-lifecycle-controller-system
PODTATO_NAMESPACE ?= podtato-kubectl
GRAFANA_PORT_FORWARD ?= 3000

.PHONY: install
install:
Expand All @@ -16,7 +17,7 @@ port-forward-jaeger:

.PHONY: port-forward-grafana
port-forward-grafana:
make -C ../observability port-forward-grafana
make -C ../observability port-forward-grafana GRAFANA_PORT_FORWARD=$(GRAFANA_PORT_FORWARD)

.PHONY: deploy-version-1
deploy-version-1:
Expand Down
11 changes: 9 additions & 2 deletions examples/kubecon-na-22-demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@ This demonstration is based on the [Observability Example](../observability) and
![img.png](assets/big-picture.png)

## Prepare Secret for Slack Notification
> kubectl create secret generic slack-notification --from-literal=SECURE_DATA='{"slack_hook":"HOOK","text":"Deployed PodTatoHead Application"}' -n podtato-kubectl -oyaml --dry-run > base/slack-secret.yaml
As a first step, create an incoming webhook according to the instructions
https://api.slack.com/messaging/webhooks

## Deploy the Observability Part
Afterwards create a secret with the created webhook
> kubectl create secret generic slack-notification --from-literal=SECURE_DATA='{"slack_hook":<YOUR_HOOK>,"text":"Deployed PodTatoHead Application"}' -n podtato-kubectl -oyaml --dry-run=client > base/slack-secret.yaml
## Deploy the Observability Part and Keptn-lifecycle-toolkit
> make install
## Port-Forward Grafana
> make port-forward-grafana
If you want to port-forward to a different port, please execute:
> make port-forward-grafana GRAFANA_PORT_FORWARD=<port>
## Import Grafana Dashboard
> make import-grafana-dashboard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ metadata:
spec:
source: prometheus
objectives:
- name: available-cpus ## this query should fail
- name: available-cpus ## this query should pass
query: "sum(kube_pod_container_resource_limits{resource='cpu'}) - sum(kube_node_status_capacity{resource='cpu'})"
evaluationTarget: ">1"
evaluationTarget: "<1"
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ metadata:
spec:
source: prometheus
objectives:
- name: available-cpus ## this query should fail
- name: available-cpus ## this query should pass
query: "sum(kube_pod_container_resource_limits{resource='cpu'}) - sum(kube_node_status_capacity{resource='cpu'})"
evaluationTarget: ">1"
evaluationTarget: "<1"
19 changes: 14 additions & 5 deletions examples/observability/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
JAEGER_VERSION ?= v1.38.0
TOOLKIT_NAMESPACE ?= keptn-lifecycle-toolkit-system
PODTATO_NAMESPACE ?= podtato-kubectl
GRAFANA_PORT_FORWARD ?= 3000

.PHONY: install
install:undeploy-podtatohead
@echo "-----------------------------------"
@echo "Create Namespace and install Keptn-lifecycle-toolkit"
@echo "-----------------------------------"
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.10.0/cert-manager.yaml
kubectl wait --for=condition=available deployment/cert-manager -n cert-manager --timeout=300s
kubectl apply -f https://github.com/keptn/lifecycle-toolkit/releases/download/v0.4.0/manifest.yaml #x-release-please-version
kubectl wait --for=condition=available deployment/klc-controller-manager -n keptn-lifecycle-toolkit-system --timeout=300s

@echo "-----------------------------------"
@echo "Create Namespace and install Jaeger"
@echo "-----------------------------------"
Expand Down Expand Up @@ -83,19 +92,19 @@ port-forward-prometheus:
.PHONY: port-forward-grafana
port-forward-grafana:
@echo ""
@echo "Open Grafana in your Browser: http://localhost:3000"
@echo "Open Grafana in your Browser: http://localhost:$(GRAFANA_PORT_FORWARD)"
@echo "CTRL-c to stop port-forward"
@echo ""
kubectl -n monitoring port-forward svc/grafana 3000
kubectl -n monitoring port-forward svc/grafana $(GRAFANA_PORT_FORWARD):3000

.PHONY: import-grafana-dashboard
import-grafana-dashboard:
@echo ""
@echo "Importing Grafana Dashboard and Datasources"
@echo ""
curl -X POST --insecure http://admin:admin@localhost:3000/api/dashboards/import -H "Content-Type: application/json" -d @./assets/grafana_dashboard_overview.json
curl -X POST --insecure http://admin:admin@localhost:3000/api/dashboards/import -H "Content-Type: application/json" -d @./assets/grafana_dashboard_workloads.json
curl -X POST --insecure http://admin:admin@localhost:3000/api/dashboards/import -H "Content-Type: application/json" -d @./assets/grafana_dashboard_applications.json
curl -X POST --insecure http://admin:admin@localhost:$(GRAFANA_PORT_FORWARD)/api/dashboards/import -H "Content-Type: application/json" -d @./assets/grafana_dashboard_overview.json
curl -X POST --insecure http://admin:admin@localhost:$(GRAFANA_PORT_FORWARD)/api/dashboards/import -H "Content-Type: application/json" -d @./assets/grafana_dashboard_workloads.json
curl -X POST --insecure http://admin:admin@localhost:$(GRAFANA_PORT_FORWARD)/api/dashboards/import -H "Content-Type: application/json" -d @./assets/grafana_dashboard_applications.json

.PHONY: uninstall
uninstall:
Expand Down
6 changes: 3 additions & 3 deletions examples/observability/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ The Collector will then be used to forward the gathered data to [Jaeger](https:/
The application deployed uses an example of pre-Deployment Evaluation based on prometheus metrics.

# TL;DR
* You can install the whole demo using: `make install`
* You can install the whole demo including Keptn-lifecycle-toolkit using: `make install`
* Deploy the PodTatoHead Demo Application: `make deploy-podtatohead`
* Afterward, see it in action as defined here: [OpenTelemetry in Action](#seeing-the-opentelemetry-collector-in-action)

## Prerequisites:

This tutorial assumes that you have both Jaeger and the Prometheus Operator installed in your Cluster.
This tutorial assumes, that you already installed the Keptn Lifecycle Controller (see https://github.com/keptn/lifecycle-toolkit). The installation instructions can be found [here](https://github.com/keptn/lifecycle-toolkit#deploy-the-latest-release).
As well, you have both Jaeger and the Prometheus Operator installed in your Cluster.
Also, please ensure that the Prometheus Operator has the required permissions to watch resources of the `keptn-lifecycle-toolkit-system` namespace (see https://prometheus-operator.dev/docs/kube/monitoring-other-namespaces/ as a reference).
For setting up both Jaeger and Prometheus, please refer to their docs:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: single-service
annotations:
keptn.sh/lifecycle-toolkit: "enabled"
---
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: test
name: test
namespace: single-service
spec:
replicas: 1
selector:
Expand Down
1 change: 1 addition & 0 deletions examples/single-service/pre-deployment-tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: lifecycle.keptn.sh/v1alpha1
kind: KeptnTaskDefinition
metadata:
name: pre-deployment-hello
namespace: single-service
spec:
function:
inline:
Expand Down
12 changes: 10 additions & 2 deletions examples/taskonly-hello-keptn/http/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ metadata:
spec:
taskDefinition: hello-keptn-http
workload: my-workload
version: "1.0"
application: my-app
appVersion: "1.0"
app: my-app
workloadVersion: "1.0"
context:
appName: my-app
appVersion: "1.0"
objectType: "task"
taskType: "pre"
workloadName: "my-workload"
workloadVersion: "1.0"
parameters:
map:
name: "Keptn-Developer"
12 changes: 10 additions & 2 deletions examples/taskonly-hello-keptn/inline/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ metadata:
spec:
taskDefinition: hello-keptn-inline
workload: my-workload
version: "1.0"
application: my-app
appVersion: "1.0"
app: my-app
workloadVersion: "1.0"
context:
appName: my-app
appVersion: "1.0"
objectType: "task"
taskType: "pre"
workloadName: "my-workload"
workloadVersion: "1.0"
parameters:
map:
name: "Keptn Developer 1"
2 changes: 1 addition & 1 deletion examples/taskonly-hello-keptn/inline/taskdefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: hello-keptn-inline
spec:
function:
inlineRef:
inline:
code: |
let text = Deno.env.get("DATA");
let data;
Expand Down
12 changes: 10 additions & 2 deletions examples/taskonly-hello-keptn/upstream/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,13 @@ metadata:
spec:
taskDefinition: hello-keptn-upstream
workload: my-workload
version: "1.0"
application: my-app
appVersion: "1.0"
app: my-app
workloadVersion: "1.0"
context:
appName: my-app
appVersion: "1.0"
objectType: "task"
taskType: "pre"
workloadName: "my-workload"
workloadVersion: "1.0"
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ spec:
function:
httpRef:
url: https://raw.githubusercontent.com/keptn/lifecycle-toolkit/main/examples/taskonly-hello-keptn/http/hello-keptn.ts
parameters:
map:
name: "Parent Developer"
parameters:
map:
name: "Parent Developer"

8 changes: 3 additions & 5 deletions operator/controllers/keptntask/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ func (r *KeptnTaskReconciler) Reconcile(ctx context.Context, req ctrl.Request) (

task.SetStartTime()

if task.Status.Status.IsPending() {
task.Status.Status = common.StateProgressing
}

defer func(task *klcv1alpha1.KeptnTask) {
err := r.Client.Status().Update(ctx, task)
if err != nil {
Expand All @@ -103,7 +99,9 @@ func (r *KeptnTaskReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
err = r.createJob(ctx, req, task)
if err != nil {
span.SetStatus(codes.Error, err.Error())
return ctrl.Result{Requeue: true}, err
r.Log.Error(err, "could not create Job")
} else {
task.Status.Status = common.StateProgressing
}
return ctrl.Result{Requeue: true, RequeueAfter: 10 * time.Second}, nil
}
Expand Down
4 changes: 3 additions & 1 deletion release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"draft": false,
"extra-files": [
"README.md",
"operator/config/manager/manager.yaml"
"operator/config/manager/manager.yaml",
"examples/argo/Makefile",
"examples/observability/Makefile"
],
"changelog-sections": [
{
Expand Down

0 comments on commit 277be10

Please sign in to comment.