Skip to content

Commit ae3742b

Browse files
authored
Merge pull request #109 from awslabs/examples
* fix: application example
2 parents 76ac30b + 5048815 commit ae3742b

File tree

3 files changed

+89
-24
lines changed

3 files changed

+89
-24
lines changed

examples/application/Readme.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# KRO Application example
2+
This example creates a ResourceGroup called `App` and then instaciates it with the default nginx container image.
3+
4+
### Create ResourceGroup called App
5+
Apply the RG to your cluster:
6+
```
7+
kubectl apply -f rg.yaml
8+
```
9+
Validate the RG status is Active:
10+
```
11+
kubectl get rg app.kro.run
12+
```
13+
Expected result:
14+
```
15+
NAME APIVERSION KIND STATE AGE
16+
app.kro.run v1alpha1 App Active 6m
17+
```
18+
19+
### Create an Instance of kind App
20+
Apply the provided instance.yaml
21+
```
22+
kubectl apply -f instance.yaml
23+
```
24+
Validate instance status:
25+
```
26+
kubectl get apps test-app
27+
```
28+
Expected result:
29+
```
30+
NAME STATE SYNCED AGE
31+
test-app ACTIVE True 16m
32+
```
33+
34+
### Validate the app is working
35+
Get the ingress url:
36+
```
37+
kubectl get ingress test-app -o jsonpath='{.status.loadBalancer.ingress[0].hostname}'
38+
```
39+
40+
Either navigate in the browser or curl it:
41+
```
42+
curl -s $(kubectl get ingress test-app -o jsonpath='{.status.loadBalancer.ingress[0].hostname}') | sed -n '/<body>/,/<\/body>/p' | sed -e 's/<[^>]*>//g'
43+
```
44+
Expected result:
45+
```
46+
Welcome to nginx!
47+
If you see this page, the nginx web server is successfully installed and
48+
working. Further configuration is required.
49+
50+
For online documentation and support please refer to
51+
nginx.org.
52+
Commercial support is available at
53+
nginx.com.
54+
55+
Thank you for using nginx.
56+
```
57+
58+
### Clean up
59+
Remove the instance:
60+
```
61+
kubectl delete apps test-app
62+
```
63+
Remove the resourcegroup:
64+
```
65+
kubectl delete rg app.kro.run
66+
```

examples/application/instance.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
apiVersion: x.symphony.k8s.aws/v1alpha1
1+
apiVersion: kro.run/v1alpha1
22
kind: App
33
metadata:
4-
name: s3demo
5-
namespace: default
4+
name: test-app
65
spec:
7-
name: s3demo
8-
image: candonov/s3-demo-app
9-
s3bucket: s3demo-11112222
6+
name: test-app
7+
port: 80 # nginx default port is 80
108
ingress:
11-
enabled: true
9+
enabled: true
10+
service: {}

examples/application/rg.yaml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,29 @@ spec:
3030
apiVersion: apps/v1
3131
kind: Deployment
3232
metadata:
33-
name: ${spec.name}
34-
namespace: ${spec.namespace}
33+
name: ${schema.spec.name}
34+
namespace: ${schema.spec.namespace}
3535
labels:
36-
app.kubernetes.io/name: ${spec.name}
36+
app.kubernetes.io/name: ${schema.spec.name}
3737
spec:
38-
replicas: ${spec.replicas}
38+
replicas: ${schema.spec.replicas}
3939
selector:
4040
matchLabels:
41-
app.kubernetes.io/name: ${spec.name}
42-
app: ${spec.name}
41+
app.kubernetes.io/name: ${schema.spec.name}
42+
app: ${schema.spec.name}
4343
template:
4444
metadata:
4545
labels:
46-
app.kubernetes.io/name: ${spec.name}
47-
app: ${spec.name}
46+
app.kubernetes.io/name: ${schema.spec.name}
47+
app: ${schema.spec.name}
4848
spec:
49-
serviceAccountName: ${spec.name}
49+
serviceAccountName: ${serviceaccount.metadata.name}
5050
containers:
5151
- name: s3-demo
52-
image: ${spec.image}
52+
image: ${schema.spec.image}
5353
imagePullPolicy: Always
5454
ports:
55-
- containerPort: ${spec.port}
55+
- containerPort: ${schema.spec.port}
5656
resources:
5757
requests:
5858
memory: "64Mi"
@@ -62,16 +62,16 @@ spec:
6262
cpu: "1"
6363
env:
6464
- name: S3_BUCKET_NAME
65-
value: ${spec.s3bucket}
65+
value: ${schema.spec.s3bucket}
6666
restartPolicy: Always
6767

6868
- name: serviceaccount
6969
template:
7070
apiVersion: v1
7171
kind: ServiceAccount
7272
metadata:
73-
name: ${spec.name}
74-
namespace: ${spec.namespace}
73+
name: ${schema.spec.name}
74+
namespace: ${schema.spec.namespace}
7575

7676
- name: service
7777
includeWhen:
@@ -84,12 +84,12 @@ spec:
8484
namespace: ${deployment.metadata.namespace}
8585
spec:
8686
selector:
87-
app: ${spec.name}
87+
app: ${schema.spec.name}
8888
ports:
8989
- name: http
9090
protocol: TCP
9191
port: 80
92-
targetPort: ${spec.port}
92+
targetPort: ${schema.spec.port}
9393

9494
- name: ingress
9595
includeWhen:
@@ -115,6 +115,6 @@ spec:
115115
pathType: Prefix
116116
backend:
117117
service:
118-
name: ${spec.name}
118+
name: ${service.metadata.name}
119119
port:
120120
number: 80

0 commit comments

Comments
 (0)