-
Notifications
You must be signed in to change notification settings - Fork 7
189 lines (179 loc) · 7.69 KB
/
pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: Primaza Pull Request Build
on:
pull_request:
branches: [ main ]
paths-ignore:
- 'scripts/**' # Ignores bash scripts
- '*.md' # Ignores .md files at the root of the repository
- '**/*.md' # Ignores .md files within subdirectories
jobs:
build:
strategy:
matrix:
java-version: [ 17 ]
uses: ./.github/workflows/checkout-maven-build.yml
with:
java-version: ${{ matrix.java-version }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
verify-in-kubernetes:
name: Verify in Kubernetes
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
cache: 'maven'
- name: Kubernetes KinD Cluster
uses: container-tools/kind-action@v2
with:
version: v0.11.1
registry: true
- name: Start Primaza
run: .github/install_primaza.sh ${{ github.repository }} ${{ github.event.pull_request.head.sha }}
- name: Register Kind cluster in Primaza
run: .github/register_local_kind_cluster_in_primaza.sh kube-system,sb
- name: Create Postgresql Service in Primaza
run: |
# First, we install Postgresql via Helm.
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install postgresql bitnami/postgresql --version 11.9.1 --set auth.username=superman --set auth.password=superman
## the service endpoint should be: "tcp:5432"
# Next, we register the Postgresql service in Primaza
.github/register_service_in_primaza.sh postgresql 11 tcp:5432 postgresql
- name: (Only if it failed) Log Primaza traces at failures
if: failure()
run: .github/print_primaza_logs.sh
# verify-e2e-example-in-kubernetes:
# name: Verify Super Hero workshop in Kubernetes
# runs-on: ubuntu-latest
# needs: [ build, verify-in-kubernetes ]
# steps:
# - uses: actions/checkout@v4
# - name: Set up JDK 17
# uses: actions/setup-java@v4
# with:
# distribution: 'temurin'
# java-version: 17
# cache: 'maven'
#
# - name: Kubernetes KinD Cluster
# uses: container-tools/kind-action@v2
# with:
# version: v0.11.1
# registry: true
#
# - name: Start Primaza
# run: .github/install_primaza.sh ${{ github.repository }} ${{ github.event.pull_request.head.sha }}
#
# - name: Install the Quarkus Super Hero application
# run: |
# KUBERNETES_NAMESPACE=app
# kubectl create namespace $KUBERNETES_NAMESPACE
#
# git clone https://github.com/quarkusio/quarkus-super-heroes
# cd quarkus-super-heroes/rest-heroes
#
# # install service binding extension
# ./mvnw quarkus:add-extension -Dextensions="quarkus-kubernetes-service-binding"
#
# # remove the third party installations via templates (we'll install these services using Primaza :) )
# rm -rf src/main/kubernetes
#
# # remove the default application.yml as we'll provide a different one with our Helm properties
# rm -rf src/main/resources/application.yml
#
# # copy the import.sql file from
# cp deploy/db-init/initialize-tables.sql src/main/resources/
#
# cat > src/main/resources/application.properties << "EOF"
# quarkus.application.name=rest-heroes
# quarkus.http.port=8080
# quarkus.hibernate-orm.sql-load-script=initialize-tables.sql
# quarkus.hibernate-orm.database.generation=drop-and-create
#
# quarkus.container-image.build=true
# quarkus.container-image.builder=docker
# quarkus.container-image.group=superhero
# quarkus.container-image.tag=1.0
# quarkus.kubernetes.deployment-target=kubernetes
# EOF
#
# # deploy super-heroes application in kind cluster
# ./mvnw clean package -DskipTests \
# -Dquarkus.container-image.push=true \
# -Dquarkus.container-image.registry=$KIND_REGISTRY \
# -Dquarkus.kubernetes.namespace=$KUBERNETES_NAMESPACE \
# -Dquarkus.kubernetes.deploy=true
#
# - name: Register Kind cluster in Primaza excluding technical namespaces for service and application discovery
# run: .github/register_local_kind_cluster_in_primaza.sh kube-system,sb
#
# - name: Wait until rest-heroes is discovered by Primaza
# run: |
# PRIMAZA_KUBERNETES_NAMESPACE=sb
# POD_NAME=$(kubectl get pod -l app.kubernetes.io/name=primaza-app -n $PRIMAZA_KUBERNETES_NAMESPACE -o name)
# APPLICATION=$(kubectl exec -i $POD_NAME --container primaza-app -n $PRIMAZA_KUBERNETES_NAMESPACE -- sh -c "curl -H 'Accept: application/json' -s localhost:8080/applications/name/rest-heroes")
# if [ $(echo "$APPLICATION" | jq -r '.name') != "rest-heroes" ]
# then
# echo "Primaza didn't discovery the rest-heroes application: $APPLICATION"
# exit 1
# fi
#
# - name: Create Postgresql Service in Primaza
# run: |
# KUBERNETES_NAMESPACE=app
# USERNAME=superman
# PASSWORD=superman
# TYPE=postgresql
# DATABASE_NAME=database
# CREDENTIAL_TYPE=basic
#
# # First, we install Postgresql via Helm.
# helm repo add bitnami https://charts.bitnami.com/bitnami
# helm install postgresql bitnami/postgresql --namespace $KUBERNETES_NAMESPACE --version 11.9.1 --set auth.username=$USERNAME --set auth.password=$PASSWORD --set auth.database=$DATABASE_NAME
# ## the service endpoint should be: "tcp:5432"
#
# # Next, we register the Postgresql service in Primaza
# .github/register_service_in_primaza.sh postgresql 11 tcp:5432 $TYPE
#
# # We create the credentials for the PostgreSQL service recently registered
# .github/register_service_credential_in_primaza.sh postgresql-credentials postgresql $USERNAME $PASSWORD $DATABASE_NAME $CREDENTIAL_TYPE
#
# - name: Register claim
# run: .github/register_claim_in_primaza.sh heroClaimDb postgresql-11
#
# - name: Bind the application to the service using the claim
# run: .github/bind_application_to_claim_in_primaza.sh rest-heroes heroClaimDb
#
# - id: wait-for-super-hero
# name: rest-heroes should now be up and running
# run: |
# KUBERNETES_NAMESPACE=app
# # Ready means that the application is now binded with the service, so we're ok!
# kubectl wait --timeout=160s --for=condition=available deployment rest-heroes -n $KUBERNETES_NAMESPACE
#
# - name: (Only if it failed) Log Primaza traces at failures
# if: failure()
# run: .github/print_primaza_logs.sh
#
# - name: (Only if it failed) Log Rest Heroes traces at failures
# if: failure()
# run: |
# KUBERNETES_NAMESPACE=app
# echo "Deployment resource:"
# kubectl get deployment rest-heroes -o yaml -n $KUBERNETES_NAMESPACE
# echo "Logs of the deployment:"
# kubectl logs deploy/rest-heroes --all-containers=true -n $KUBERNETES_NAMESPACE
# echo "Print secret: "
# kubectl get secret rest-heroes-secret -o yaml -n $KUBERNETES_NAMESPACE
# POD_NAME=$(kubectl get pod -l app.kubernetes.io/name=rest-heroes -n $KUBERNETES_NAMESPACE -o name)
# echo "Describe pod:"
# kubectl describe $POD_NAME -n $KUBERNETES_NAMESPACE
# echo "Logs of running pod:"
# kubectl logs $POD_NAME -n $KUBERNETES_NAMESPACE
# echo "Logs of terminated pod:"
# kubectl logs -p $POD_NAME -n $KUBERNETES_NAMESPACE