Skip to content

Commit

Permalink
Add manifests and github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
t-persson committed Jun 4, 2024
1 parent 21f6e21 commit 3b70e45
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 2 deletions.
36 changes: 34 additions & 2 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,39 @@ jobs:
echo "::set-output name=version::$VERSION"
outputs:
sseVersion: ${{ steps.image.outputs.version }}
build_logarea:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build app image
run: docker build . -f deploy/etos-logarea/Dockerfile --tag image

- name: Log into registry
run: echo "${{ secrets.REGISTRYPASSWORD }}" | docker login registry.nordix.org -u ${{ secrets.REGISTRYUSERNAME }} --password-stdin

- name: Push app image
id: image
run: |
IMAGE_ID=registry.nordix.org/eiffel/etos-logarea
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=$(echo ${{ github.sha }} | cut -c1-8)
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag image $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
echo $IMAGE_ID:$VERSION
echo "::set-output name=version::$VERSION"
outputs:
logAreaVersion: ${{ steps.image.outputs.version }}
update_manifests:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true }}
runs-on: ubuntu-latest
needs: [build_api, build_sse]
needs: [build_api, build_sse, build_logarea]
steps:
- uses: actions/checkout@v3
- name: Update manifests
Expand All @@ -83,7 +112,10 @@ jobs:
"manifests/base/deployment.yaml": {
"spec.template.spec.containers[0].image": "registry.nordix.org/eiffel/etos-api:${{ needs.build_api.outputs.apiVersion }}"
}
"manifests/base/logarea/deployment.yaml": {
"spec.template.spec.containers[0].image": "registry.nordix.org/eiffel/etos-logarea:${{ needs.build_logarea.outputs.logAreaVersion }}"
},
}
branch: main
commitChange: true
message: Updating SSE image to ${{ needs.build_sse.outputs.sseVersion }} and API image to ${{ needs.build_api.outputs.apiVersion }}
message: Updating SSE image to ${{ needs.build_sse.outputs.sseVersion }}, LogArea image to ${{ needs.build_logarea.outputs.logAreaVersion }} and API image to ${{ needs.build_api.outputs.apiVersion }}
9 changes: 9 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ jobs:
uses: hadolint/hadolint-action@master
with:
dockerfile: deploy/etos-sse/Dockerfile
- name: Run hadolint for LogArea
uses: hadolint/hadolint-action@master
with:
dockerfile: deploy/etos-logarea/Dockerfile

build-docker-images:
# The type of runner that the job will run on
Expand All @@ -66,3 +70,8 @@ jobs:
with:
context: .
file: ./deploy/etos-sse/Dockerfile
- name: Build LogArea image
uses: docker/build-push-action@v2
with:
context: .
file: ./deploy/etos-logarea/Dockerfile
1 change: 1 addition & 0 deletions manifests/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ resources:
- service.yaml
- deployment.yaml
- ./sse
- ./logarea


# By generating the configmap it will get a unique name on each apply
Expand Down
39 changes: 39 additions & 0 deletions manifests/base/logarea/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: etos-api
app.kubernetes.io/part-of: etos
app.kubernetes.io/component: logarea
name: etos-logarea
spec:
selector:
matchLabels:
app.kubernetes.io/name: etos-api
app.kubernetes.io/component: logarea
template:
metadata:
labels:
app.kubernetes.io/name: etos-api
app.kubernetes.io/component: logarea
spec:
serviceAccountName: etos-logarea
containers:
- name: etos-logarea
image: registry.nordix.org/eiffel/etos-logarea:79d0522b
imagePullPolicy: IfNotPresent
env:
- name: SERVICE_HOST
value: 0.0.0.0
ports:
- name: http
containerPort: 8080
protocol: TCP
livenessProbe:
httpGet:
path: /v1alpha/selftest/ping
port: http
readinessProbe:
httpGet:
path: /v1alpha/selftest/ping
port: http
6 changes: 6 additions & 0 deletions manifests/base/logarea/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- service-account.yaml
- service.yaml
- deployment.yaml
8 changes: 8 additions & 0 deletions manifests/base/logarea/service-account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/name: etos-api
app.kubernetes.io/part-of: etos
app.kubernetes.io/component: logarea
name: etos-logarea
18 changes: 18 additions & 0 deletions manifests/base/logarea/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/name: etos-api
app.kubernetes.io/part-of: etos
app.kubernetes.io/component: logarea
name: etos-logarea
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: http
selector:
app.kubernetes.io/name: etos-api
app.kubernetes.io/component: logarea
type: ClusterIP

0 comments on commit 3b70e45

Please sign in to comment.