Skip to content

Commit 09f4ea7

Browse files
init pr (#2)
* init commit
1 parent 6b6b8db commit 09f4ea7

File tree

15 files changed

+643
-0
lines changed

15 files changed

+643
-0
lines changed

.github/workflows/build-chart.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Release Charts
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
permissions:
11+
contents: write
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Configure Git
20+
run: |
21+
git config user.name "$GITHUB_ACTOR"
22+
git config user.email "[email protected]"
23+
24+
- name: Install Helm
25+
uses: azure/setup-helm@v3
26+
27+
- name: Run chart-releaser
28+
uses: helm/[email protected]
29+
with:
30+
skip_existing: true
31+
packages_with_index: true
32+
env:
33+
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

.github/workflows/push-image.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Docker Image
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
docker:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout Repository
13+
uses: actions/checkout@v3
14+
15+
- name: Generate Docker Metadata
16+
id: meta
17+
uses: docker/metadata-action@v4
18+
with:
19+
images: ghcr.io/${{ github.repository }}
20+
tags: |
21+
type=ref,event=tag
22+
type=semver,pattern={{version}}
23+
type=semver,pattern={{major}}.{{minor}}
24+
flavor: latest=true
25+
26+
- name: Setup Docker Buildx
27+
uses: docker/setup-buildx-action@v2
28+
29+
- name: Login to GitHub Container Registry
30+
uses: docker/login-action@v2
31+
with:
32+
registry: ghcr.io
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Build and Push Docker Image
37+
uses: docker/build-push-action@v3
38+
env:
39+
DOCKER_BUILDKIT: 1
40+
with:
41+
context: .
42+
file: Dockerfile
43+
push: true
44+
tags: ${{ steps.meta.outputs.tags }}
45+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM golang:1.23 AS builder
2+
WORKDIR /app
3+
4+
COPY main.go .
5+
RUN go mod init helm-scraper && go mod tidy
6+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o helm-scraper main.go
7+
8+
FROM alpine:latest
9+
WORKDIR /root/
10+
11+
ENV CLUSTER_NAME="minikube"
12+
COPY --from=builder /app/helm-scraper /root/helm-scraper
13+
RUN chmod +x /root/helm-scraper
14+
15+
ENTRYPOINT ["/root/helm-scraper"]

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
# keepup-helm-scraper
2+
3+
## TO DO

charts/helm-scraper/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

charts/helm-scraper/Chart.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v2
2+
name: helm-scraper
3+
description: A Helm chart for scrape charts release information.
4+
type: application
5+
version: 0.1.0
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "helm-scraper.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "helm-scraper.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "helm-scraper.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "helm-scraper.labels" -}}
37+
helm.sh/chart: {{ include "helm-scraper.chart" . }}
38+
{{ include "helm-scraper.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "helm-scraper.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "helm-scraper.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "helm-scraper.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "helm-scraper.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: scraper-role
5+
rules:
6+
- apiGroups: [""]
7+
resources: ["namespaces", "secrets"]
8+
verbs: ["get", "list"]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
name: scraper-rolebinding
5+
subjects:
6+
- kind: ServiceAccount
7+
name: {{ .Values.serviceAccount.name }}
8+
namespace: default
9+
roleRef:
10+
kind: ClusterRole
11+
name: scraper-role
12+
apiGroup: rbac.authorization.k8s.io
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apiVersion: batch/v1
2+
kind: CronJob
3+
metadata:
4+
name: helm-release-scraper
5+
namespace: default
6+
spec:
7+
schedule: "{{ .Values.cronjob.schedule }}"
8+
successfulJobsHistoryLimit: 3
9+
failedJobsHistoryLimit: 1
10+
jobTemplate:
11+
spec:
12+
template:
13+
spec:
14+
serviceAccountName: {{ .Values.serviceAccount.name }}
15+
restartPolicy: {{ .Values.cronjob.restartPolicy }}
16+
containers:
17+
- name: helm-scraper
18+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
19+
imagePullPolicy: "{{ .Values.image.pullPolicy }}"
20+
env:
21+
- name: CLUSTER_NAME
22+
value: "{{ .Values.cluster.name }}"
23+
- name: API_URL
24+
value: "{{ .Values.api.url }}"
25+
- name: API_TOKEN
26+
value: "{{ .Values.api.token }}"

0 commit comments

Comments
 (0)