Skip to content

Commit

Permalink
feat: Use go-sdk and remove distributor (#159)
Browse files Browse the repository at this point in the history
* feat: Use go-sdk and remove distributor

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* Fix unit tests

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* Changed event wildcard

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* E2E event debugging

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* Log Event type and source

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* Add action logs for debugging

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* Add additional logs to Github action

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* Add additional logs to Github action

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* Change action logs

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* Add environment variables to Helm chart + Move handlers into different package

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* Set LOG_LEVEL to debug

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* Add PUBSUB_TOPIC to Helm chart

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* Move PUBSUB_TOPIC into Helm value + code cleanup

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* Clean up code

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* Change Helm values

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* Add subscription.pubsubTopic to README

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* Remove unneeded Helm value

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* Add SSL verification to remote execution plane

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* Added apiValidateTls validation

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>
  • Loading branch information
TannerGabriel authored Aug 10, 2022
1 parent 5d6e811 commit 8aafd2c
Show file tree
Hide file tree
Showing 17 changed files with 447 additions and 1,189 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
- name: Install Keptn
id: install_keptn
uses: keptn-sandbox/action-install-keptn@v2.0.0
uses: keptn-sandbox/action-install-keptn@v3.0.0
timeout-minutes: 5
with:
KEPTN_VERSION: ${{ matrix.keptn-version }}
Expand Down Expand Up @@ -169,7 +169,12 @@ jobs:
kubectl describe nodes > k8s_debug/k8s_describe_nodes.txt
kubectl cluster-info dump > k8s_debug/k8s_cluster_info_dump.txt
kubectl get all -n keptn -o json > k8s_debug/k8s_keptn_objects.json
kubectl get events -n keptn --sort-by='.metadata.creationTimestamp' -A > k8s_debug/keptn_events.txt
kubectl logs -n keptn -l app.kubernetes.io/instance=keptn --prefix=true --previous=false --all-containers > k8s_debug/k8s_keptn_logs.txt || true
kubectl logs -n keptn -l app.kubernetes.io/instance=keptn-service-template-go --prefix=true --previous=false --all-containers > k8s_debug/service_template_logs.txt || true
kubectl logs -n keptn -l app.kubernetes.io/instance=keptn-service-template-go --prefix=true --previous=true --all-containers > k8s_debug/service_template_logs_previous.txt || true
kubectl describe pod -n keptn -l app.kubernetes.io/instance=keptn-service-template-go > k8s_debug/keptn_service_template_describe.txt || true
kubectl logs deployment/keptn-service-template-go -n keptn > k8s_debug/keptn_service_template_deployment_logs.txt || true
kubectl logs deployment/keptn-gitea-provisioner-service --prefix=true --previous=false --all-containers > k8s_debug/k8s_gitea_provisioner_logs.txt || true
kubectl get statefulsets,configmaps,pods,networkpolicy,serviceaccounts,role,rolebindings,events,services -n ${GITEA_NAMESPACE} -o json > k8s_debug/k8s_objects_gitea.json
kubectl logs statefulsets/gitea --prefix=true --previous=false --all-containers -n ${GITEA_NAMESPACE} > k8s_debug/k8s_logs_gitea.txt || true
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Examples:

* Webhooks: https://keptn.sh/docs/0.14.x/integrations/webhooks/
* Webhooks: https://keptn.sh/docs/0.17.x/integrations/webhooks/
* Job-Executor-Service: https://github.com/keptn-sandbox/job-executor-service

---
Expand Down Expand Up @@ -33,9 +33,9 @@ This implements a keptn-service-template-go for Keptn. If you want to learn more

| Keptn Version* | [Keptn-service-template-go version](https://github.com/keptn-sandbox/keptn-service-template-go/releases) |
|:--------------:|:--------------------------------------------------------------------------------------------------------:|
| 0.13.x | 0.13.0 |
| 0.14.x | 0.14.0 |
| 0.17.x | 0.17.0 |
| 0.13.x | 0.13.0 |
| 0.14.x | 0.14.0 |
| 0.17.x | 0.17.0 |


\* This is the Keptn version we aim to be compatible with. Other versions should work too, but there is no guarantee.
Expand All @@ -56,7 +56,7 @@ for example:
helm install -n keptn keptn-service-template-go chart/
```

This should install the `keptn-service-template-go` together with a Keptn `distributor` into the `keptn` namespace, which you can verify using
This should install the `keptn-service-template-go` into the `keptn` namespace, which you can verify using

```console
kubectl -n keptn get deployment keptn-service-template-go -o wide
Expand Down
56 changes: 22 additions & 34 deletions chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,25 @@ Helm Chart for the keptn keptn-service-template-go

The following table lists the configurable parameters of the keptn-service-template-go chart and their default values.

| Parameter | Description | Default |
| ------------------------ | ----------------------- | -------------- |
| `image.repository` | Container image name | `"ghcr.io/keptn-sandbox/keptn-service-template-go"` |
| `image.pullPolicy` | Kubernetes image pull policy | `"IfNotPresent"` |
| `image.tag` | Container tag | `""` |
| `service.enabled` | Creates a kubernetes service for the keptn-service-template-go | `true` |
| `distributor.stageFilter` | Sets the stage this helm service belongs to | `""` |
| `distributor.serviceFilter` | Sets the service this helm service belongs to | `""` |
| `distributor.projectFilter` | Sets the project this helm service belongs to | `""` |
| `distributor.pubsubTopic` | Sets the events the service subscribes to. *NOTE: in case of remote control plane wildcards like "sh.keptn.>" don't work, please provide a comma-separated list of explicit events* | `"sh.keptn.>"` |
| `distributor.image.repository` | Container image name | `"docker.io/keptn/distributor"` |
| `distributor.image.pullPolicy` | Kubernetes image pull policy | `"IfNotPresent"` |
| `distributor.image.tag` | Container tag | `""` |
| `remoteControlPlane.enabled` | Enables remote execution plane mode | `false` |
| `remoteControlPlane.api.protocol` | Used protocol (http, https | `"https"` |
| `remoteControlPlane.api.hostname` | Hostname of the control plane cluster (and port) | `""` |
| `remoteControlPlane.api.apiValidateTls` | Defines if the control plane certificate should be validated | `true` |
| `remoteControlPlane.api.token` | Keptn api token | `""` |
| `imagePullSecrets` | Secrets to use for container registry credentials | `[]` |
| `serviceAccount.create` | Enables the service account creation | `true` |
| `serviceAccount.annotations` | Annotations to add to the service account | `{}` |
| `serviceAccount.name` | The name of the service account to use. | `""` |
| `podAnnotations` | Annotations to add to the created pods | `{}` |
| `podSecurityContext` | Set the pod security context (e.g. fsgroups) | `{}` |
| `securityContext` | Set the security context (e.g. runasuser) | `{}` |
| `resources` | Resource limits and requests | `{}` |
| `nodeSelector` | Node selector configuration | `{}` |
| `tolerations` | Tolerations for the pods | `[]` |
| `affinity` | Affinity rules | `{}` |





| Parameter | Description | Default |
|-----------------------------------------|----------------------------------------------------------------|-----------------------------------------------------|
| `image.repository` | Container image name | `"ghcr.io/keptn-sandbox/keptn-service-template-go"` |
| `image.pullPolicy` | Kubernetes image pull policy | `"IfNotPresent"` |
| `image.tag` | Container tag | `""` |
| `service.enabled` | Creates a kubernetes service for the keptn-service-template-go | `true` |
| `remoteControlPlane.enabled` | Enables remote execution plane mode | `false` |
| `remoteControlPlane.api.protocol` | Used protocol (http, https | `"https"` |
| `remoteControlPlane.api.hostname` | Hostname of the control plane cluster (and port) | `""` |
| `remoteControlPlane.api.token` | Keptn api token | `""` |
| `imagePullSecrets` | Secrets to use for container registry credentials | `[]` |
| `serviceAccount.create` | Enables the service account creation | `true` |
| `serviceAccount.annotations` | Annotations to add to the service account | `{}` |
| `serviceAccount.name` | The name of the service account to use. | `""` |
| `podAnnotations` | Annotations to add to the created pods | `{}` |
| `podSecurityContext` | Set the pod security context (e.g. fsgroups) | `{}` |
| `securityContext` | Set the security context (e.g. runasuser) | `{}` |
| `resources` | Resource limits and requests | `{}` |
| `nodeSelector` | Node selector configuration | `{}` |
| `tolerations` | Tolerations for the pods | `[]` |
| `affinity` | Affinity rules | `{}` |
| `subscription.pubsubTopic` | Sets the events the service subscribes to | `"sh.keptn.>"` |
145 changes: 42 additions & 103 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
name: {{ include "keptn-service.fullname" . }}
labels:
{{- include "keptn-service.labels" . | nindent 4 }}

spec:
replicas: 1
selector:
Expand All @@ -31,113 +30,53 @@ spec:
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
livenessProbe:
httpGet:
path: /health
port: 8080
readinessProbe:
httpGet:
path: /ready
port: 8080
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: 80
env:
- name: CONFIGURATION_SERVICE
value: "http://localhost:8081/configuration-service"
- name: env
value: 'production'
- name: LOG_LEVEL
value: 'debug'
- name: PUBSUB_TOPIC
value: {{ .Values.subscription.pubsubTopic }}
- name: K8S_DEPLOYMENT_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: 'metadata.labels[''app.kubernetes.io/name'']'
- name: K8S_DEPLOYMENT_VERSION
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: 'metadata.labels[''app.kubernetes.io/version'']'
- name: K8S_DEPLOYMENT_COMPONENT
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: 'metadata.labels[''app.kubernetes.io/component'']'
- name: K8S_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: K8S_NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
- name: K8S_POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
{{- if .Values.remoteControlPlane.enabled }}
- name: KEPTN_API_ENDPOINT
value: "{{ .Values.remoteControlPlane.api.protocol }}://{{ .Values.remoteControlPlane.api.hostname }}/api"
- name: KEPTN_API_TOKEN
value: "{{ .Values.remoteControlPlane.api.token }}"
- name: HTTP_SSL_VERIFY
value: "{{ .Values.remoteControlPlane.api.apiValidateTls | default "true" }}"
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
- name: distributor
image: "{{ .Values.distributor.image.repository }}:{{ .Values.distributor.image.tag | default .Chart.AppVersion }}"
livenessProbe:
httpGet:
path: /health
port: 8080
readinessProbe:
httpGet:
path: /ready
port: 8080
lifecycle:
preStop:
exec:
command: [ "/bin/sleep","60" ]
imagePullPolicy: Always
ports:
- containerPort: 8080
resources:
requests:
memory: "32Mi"
cpu: "50m"
limits:
memory: "128Mi"
cpu: "500m"
env:
- name: PUBSUB_URL
value: 'nats://keptn-nats'
- name: PUBSUB_TOPIC
value: {{ .Values.distributor.pubsubTopic }}
- name: PUBSUB_RECIPIENT
value: '127.0.0.1'
- name: STAGE_FILTER
value: "{{ .Values.distributor.stageFilter }}"
- name: PROJECT_FILTER
value: "{{ .Values.distributor.projectFilter }}"
- name: SERVICE_FILTER
value: "{{ .Values.distributor.serviceFilter }}"
- name: VERSION
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: 'metadata.labels[''app.kubernetes.io/version'']'
- name: DISTRIBUTOR_VERSION
value: {{ .Values.distributor.image.tag | default .Chart.AppVersion }}
- name: K8S_DEPLOYMENT_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: 'metadata.labels[''app.kubernetes.io/name'']'
- name: K8S_POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: K8S_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: K8S_NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
{{- if .Values.remoteControlPlane.enabled }}
- name: KEPTN_API_ENDPOINT
value: "{{ .Values.remoteControlPlane.api.protocol }}://{{ .Values.remoteControlPlane.api.hostname }}/api"
- name: KEPTN_API_TOKEN
value: "{{ .Values.remoteControlPlane.api.token }}"
- name: HTTP_SSL_VERIFY
value: "{{ .Values.remoteControlPlane.api.apiValidateTls | default "true" }}"
{{- end }}
{{- if (((.Values.distributor).config).queueGroup).enabled | default true }}
- name: PUBSUB_GROUP
valueFrom:
fieldRef:
fieldPath: metadata.labels['app.kubernetes.io/name']
{{- end }}

{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: 60
30 changes: 0 additions & 30 deletions chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,36 +64,6 @@
}
}
}
},
"distributor": {
"type": "object",
"required": [
"image"
],
"properties": {
"image": {
"properties": {
"repository": {
"pattern": "[a-z][a-z0-9-./]{2,63}$"
},
"pullPolicy": {
"enum": [
"IfNotPresent",
"Always"
]
}
}
},
"stageFilter": {
"pattern": "^$|[A-Za-z0-9-.]{2,63}$"
},
"serviceFilter": {
"pattern": "^$|[A-Za-z0-9-.]{2,63}$"
},
"projectFilter": {
"pattern": "^$|[A-Za-z0-9-.]{2,63}$"
}
}
}
}
}
16 changes: 3 additions & 13 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,16 @@ image:
service:
enabled: true # Creates a Kubernetes Service for the keptn-service-template-go

distributor:
stageFilter: "" # Sets the stage this helm service belongs to
serviceFilter: "" # Sets the service this helm service belongs to
projectFilter: "" # Sets the project this helm service belongs to
subscription:
pubsubTopic: "sh.keptn.>" # Sets the events the service subscribes to
image:
repository: docker.io/keptn/distributor # Container Image Name
pullPolicy: IfNotPresent # Kubernetes Image Pull Policy
tag: "0.17.0" # Container Tag
config:
queueGroup:
enabled: true # Enable connection via Nats queue group to support exactly-once message processing

remoteControlPlane:
enabled: false # Enables remote execution plane mode
api:
protocol: "http" # Used Protocol (http, https)
hostname: "" # Hostname of the control plane cluster (and Port)
apiValidateTls: true # Defines if the control plane certificate should be validated
hostname: "api-gateway-nginx.keptn" # Hostname of the control plane cluster (and Port)
token: "" # Keptn API Token
apiValidateTls: true # Defines if the control plane certificate should be validated

imagePullSecrets: [] # Secrets to use for container registry credentials

Expand Down
Loading

0 comments on commit 8aafd2c

Please sign in to comment.