File tree 8 files changed +619
-19
lines changed
internal/configure-pipeline
workflows/resource/configure/instance/security-scan
blog/2025-03-05-debugging
8 files changed +619
-19
lines changed Original file line number Diff line number Diff line change
1
+ export PATH=" $( pwd) /internal/scripts:$PATH "
Original file line number Diff line number Diff line change @@ -21,25 +21,27 @@ if [ -n "${configMapDomain}" ]; then
21
21
domainPort=" ${configMapDomainPort} "
22
22
fi
23
23
24
+ mkdir /kratix/output/${lifecycle}
25
+
24
26
kubectl create deployment ${name} \
25
27
--image=${image} --namespace=${namespace} \
26
28
--replicas=${replicas} \
27
29
--dry-run=client -o yaml > deployment.yaml
28
30
29
- yq ' .spec.template.spec.containers[0].env = env(applicationEnv)' deployment.yaml > /kratix/output/deployment.yaml
31
+ yq ' .spec.template.spec.containers[0].env = env(applicationEnv)' deployment.yaml > /kratix/output/${lifecycle} / deployment.yaml
30
32
31
33
kubectl create service nodeport ${name} \
32
34
--namespace=${namespace} \
33
35
--tcp=${service_port} \
34
36
--dry-run=client \
35
- --output yaml > /kratix/output/service.yaml
37
+ --output yaml > /kratix/output/${lifecycle} / service.yaml
36
38
37
39
kubectl create ingress ${name} \
38
40
--namespace=${namespace} \
39
41
--class=" nginx" \
40
42
--rule=" ${name} .${namespace} .${domain} /*=${name} :${service_port} " \
41
43
--dry-run=client \
42
- --output yaml > /kratix/output/ingress.yaml
44
+ --output yaml > /kratix/output/${lifecycle} / ingress.yaml
43
45
44
46
echo " " "
45
47
- matchLabels:
Original file line number Diff line number Diff line change
1
+ apiVersion : platform.kratix.io/v1alpha1
2
+ kind : PromiseRelease
3
+ metadata :
4
+ name : runtime
5
+ spec :
6
+ version : v1.0.0
7
+ sourceRef :
8
+ type : http
9
+ url : https://raw.githubusercontent.com/syntasso/kratix-marketplace/refs/heads/main/runtime/promise.yaml
Original file line number Diff line number Diff line change 1
1
apiVersion : platform.kratix.io/v1alpha1
2
2
kind : Promise
3
3
metadata :
4
- name : runtime
5
4
labels :
6
5
kratix.io/promise-version : v1.0.0
6
+ name : runtime
7
7
spec :
8
- destinationSelectors :
9
- - matchLabels :
10
- environment : dev
11
8
api :
12
9
apiVersion : apiextensions.k8s.io/v1
13
10
kind : CustomResourceDefinition
75
72
type : object
76
73
served : true
77
74
storage : true
75
+ destinationSelectors :
76
+ - matchLabels :
77
+ environment : dev
78
78
workflows :
79
79
promise :
80
80
configure :
@@ -91,19 +91,12 @@ spec:
91
91
- apiVersion : platform.kratix.io/v1alpha1
92
92
kind : Pipeline
93
93
metadata :
94
+ creationTimestamp : null
94
95
name : instance
95
96
spec :
96
- rbac :
97
- permissions :
98
- - apiGroups :
99
- - " "
100
- resources :
101
- - configmaps
102
- verbs :
103
- - get
104
- - list
105
- resourceNames : [ runtime-domain ]
106
97
containers :
107
- - image : ghcr.io/syntasso/kratix-marketplace/runtime-configure-pipeline:v0.1.0
98
+ - command :
99
+ - resource-configure
100
+ image : ghcr.io/syntasso/kratix-docs/runtime-configure-pipeline:v0.1.0
108
101
name : resource-configure
109
- command : [ resource-configure ]
102
+ status : {}
Original file line number Diff line number Diff line change
1
+ FROM "alpine"
2
+
3
+ RUN apk update && apk add --no-cache yq curl
4
+
5
+ RUN curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.18.3
6
+
7
+ ADD scripts/pipeline.sh /usr/bin/pipeline.sh
8
+ ADD resources resources
9
+
10
+ RUN chmod +x /usr/bin/pipeline.sh
11
+
12
+ CMD [ "sh" , "-c" , "pipeline.sh" ]
13
+ ENTRYPOINT []
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env sh
2
+
3
+ set -ex
4
+
5
+ image=" $( yq eval ' .spec.image' /kratix/input/object.yaml) "
6
+
7
+ echo " Scanning ${image} "
8
+
9
+ if [ $DEBUG = " true" ]; then
10
+ DEBUG_MODE=true
11
+ echo " Running in debug mode"
12
+ else
13
+ DEBUG_MODE=false
14
+ fi
15
+
16
+ TRIVY_DEBUG=$DEBUG_MODE trivy image --format=json --output=results.json " ${image} " > results.json
17
+
18
+ health_state=" healthy"
19
+
20
+ if [ " $( jq ' .[] | select(.Vulnerabilities != null) | length' results.json) " != " " ]; then
21
+ health_state=" degraded"
22
+ fi
23
+
24
+ resource_name=$( yq ' .metadata.name' /kratix/input/object.yaml)
25
+ namespace=" default"
26
+
27
+ mkdir -p /kratix/output/platform/
28
+
29
+ cat << EOF > /kratix/output/platform/health-record.yaml
30
+ apiVersion: platform.kratix.io/v1alpha1
31
+ kind: HealthRecord
32
+ metadata:
33
+ name: runtime-${resource_name}
34
+ namespace: ${namespace}
35
+ data:
36
+ promiseRef:
37
+ name: runtime
38
+ resourceRef:
39
+ name: ${resource_name}
40
+ namespace: ${namespace}
41
+ state: ${health_state}
42
+ lastRun: $( date +%s)
43
+ details:
44
+ results: ""
45
+ EOF
46
+
47
+ cat results.json | yq -P > results.yaml
48
+ yq e -i ' .data.details.results = load("results.yaml")' /kratix/output/platform/health-record.yaml
49
+
50
+ cat << EOF > /kratix/metadata/destination-selectors.yaml
51
+ - directory: platform
52
+ matchLabels:
53
+ environment: platform
54
+ EOF
You can’t perform that action at this time.
0 commit comments