Skip to content

Commit

Permalink
Monitoring client for Harbor (#4)
Browse files Browse the repository at this point in the history
* Adding Harbor-client

* add harbor-client helm chart and workflows

* Modify helm chart for harbor client

* Changes on Dockerfile and secret name

* Deleting DS_Store files

* Changing image.repository in values.yaml

* review changes

* changes on env file.

---------

Co-authored-by: Mahsa <mahsa.soleimani@snapp.cab>
  • Loading branch information
divergentluna and Mahsa authored Jan 9, 2024
1 parent 9005990 commit 742f475
Show file tree
Hide file tree
Showing 14 changed files with 703 additions and 60 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/harbor-realese.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Release Helm Chart

on:
push:
tags:
- 'harbor-release-v*'

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Package Helm Charts
run: |
helm package clients/harbor-client/deploy -d clients/helm-charts
- name: Determine Chart to Publish
id: determine_chart
run: |
CHART_TO_PUBLISH=$(find clients/helm-charts -type f -name '*.tgz' | head -n 1)
echo "Chart to publish: $CHART_TO_PUBLISH"
echo "::set-output name=chart_to_publish::$CHART_TO_PUBLISH"
- name: Publish GitHub Release
uses: softprops/action-gh-release@v1
with:
files: ${{ steps.determine_chart.outputs.chart_to_publish }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32 changes: 32 additions & 0 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build Container Image

on:
push:
branches:
- main

jobs:
docker:
name: docker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
with:
platforms: amd64
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image
run: |
for dir in clients/*/; do
docker buildx build \
--file $dir/Dockerfile \
--tag ghcr.io/${{ github.repository }}/$dir:latest \
$dir
docker push ghcr.io/${{ github.repository }}/$dir:latest
done
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*.so
*.dylib
.idea/
.DS_Store

# Test binary, built with `go test -c`
*.test
Expand All @@ -20,3 +21,6 @@ vendor/

# Go workspace file
go.work

#env files
.env
19 changes: 19 additions & 0 deletions clients/harbor-client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM golang:alpine AS builder

WORKDIR /go/src/app

COPY . .

RUN go build -o app

FROM alpine:latest

WORKDIR /app

COPY --from=builder /go/src/app/app .

ENV IMAGE_REFERENCE="The image reference URL starts with //."

EXPOSE 8080

CMD ["./app"]
7 changes: 7 additions & 0 deletions clients/harbor-client/deploy/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: snappcloud-harbor-client
description: A Helm chart for Kubernetes

type: application
version: 0.1.0
appVersion: "0.0.1"
46 changes: 46 additions & 0 deletions clients/harbor-client/deploy/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "snappcloud-harbor-client.fullname" . }}
labels:
{{- include "snappcloud-harbor-client.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "snappcloud-harbor-client.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "snappcloud-harbor-client.selectorLabels" . | nindent 8 }}
annotations:
{{- .Values.podAnnotations | toYaml | nindent 8 }}
spec:
serviceAccountName: {{ include "snappcloud-harbor-client.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
env:
- name: IMAGE_REFERENCE
valueFrom:
secretKeyRef:
name: {{ .Values.configSecretName }}
key: IMAGE_REFERENCE
{{ .Values.nodeSelector | toYaml | nindent 8 }}
tolerations:
{{- with .Values.tolerations }}
{{- toYaml . | nindent 8 }}
{{- end }}
affinity:
{{- with .Values.affinity }}
{{- toYaml . | nindent 8 }}
{{- end }}
9 changes: 9 additions & 0 deletions clients/harbor-client/deploy/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Values.configSecretName }}
labels:
{{- include "snappcloud-harbor-client.labels" . | nindent 4 }}
type: Opaque
stringData:
IMAGE_REFERENCE: "The image reference URL starts with //."
14 changes: 14 additions & 0 deletions clients/harbor-client/deploy/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "snappcloud-harbor-client.fullname" . }}
labels:
{{- include "snappcloud-harbor-client.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
selector:
{{- include "snappcloud-harbor-client.selectorLabels" . | nindent 4 }}
37 changes: 37 additions & 0 deletions clients/harbor-client/deploy/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
replicaCount: 1

image:
repository: ghcr.io/snapp-incubator/snappcloud-status-backend
pullPolicy: Always
tag: "0.0.1"

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

serviceAccount:
create: false
automount: true
annotations: {}
name: ""

service:
type: ClusterIP
port: 8080

resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi

autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80

configSecretName: spcld-harbor-health-client
43 changes: 43 additions & 0 deletions clients/harbor-client/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module github.com/snapp-incubator/snappcloud-status-backend/clients/harbor-client

go 1.21.0

require (
github.com/containers/image v3.0.2+incompatible
github.com/prometheus/client_golang v1.17.0
)

require (
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/containers/storage v1.51.0 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker v24.0.7+incompatible // indirect
github.com/docker/docker-credential-helpers v0.8.0 // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-metrics v0.0.1 // indirect
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/stretchr/testify v1.8.4 // indirect
golang.org/x/mod v0.11.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sync v0.4.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/tools v0.8.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Loading

0 comments on commit 742f475

Please sign in to comment.