Skip to content

Commit

Permalink
Allow passing volumes & volumeMounts in values (#95)
Browse files Browse the repository at this point in the history
* Allow passing `volumes` & `volumeMounts` in values

* Format YAML

* Updates to CI
  • Loading branch information
amimof authored Oct 17, 2024
1 parent ead21da commit e0ac2e8
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 148 deletions.
84 changes: 37 additions & 47 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,56 @@ name: Go

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:
verify:
staticcheck:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '>=1.21.0'
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21

- name: Check Formating
run: make checkfmt
- name: Format Code
run: make fmt
- name: Go Vet
run: make vet
- name: Go Race
run: make race
- name: Gocyclo
run: make gocyclo
- name: Lint
run: make lint
- name: Ineffassign
run: make ineffassign
- name: Misspell
run: make misspell
- name: Helm Lint
run: make helm_lint
- name: Lint
run: make lint
- name: Go Vet
run: make vet
- name: Helm Lint
run: make helm_lint

test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21

- name: Test
run: make test
- name: Race
run: make race
- name: Benchmark
run: make benchmark
- name: Coverage
run: make coverage

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '>=1.21.0'

- name: Test
run: make test
- name: Benchmark
run: make benchmark
- name: Coverage
run: make coverage

build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ">=1.21.0"

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '>=1.21.0'

- name: Compile
run: make
- name: Compile
run: make
104 changes: 52 additions & 52 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: Release
on:
push:
tags:
- "v*"
- "v*"
branches:
- "master"
- "master"

env:
REGISTRY: ghcr.io
Expand All @@ -15,60 +15,60 @@ jobs:
helm:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.4.0

- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.2.0
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.13.3

- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.6.0
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

releases:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '>=1.21.0'

- name: Build Binaries
run: |
# Linux
GOOS=linux GOARCH=amd64 BUILDPATH=./bin/node-cert-exporter-linux-amd64 make
GOOS=linux GOARCH=arm BUILDPATH=./bin/node-cert-exporter-linux-arm make
GOOS=linux GOARCH=arm64 BUILDPATH=./bin/node-cert-exporter-linux-arm64 make
GOOS=linux GOARCH=386 BUILDPATH=./bin/node-cert-exporter-linux-386 make
# Windows
GOOS=windows GOARCH=amd64 BUILDPATH=./bin/node-cert-exporter-windows-amd64.exe make
GOOS=windows GOARCH=arm BUILDPATH=./bin/node-cert-exporter-windows-arm.exe make
GOOS=windows GOARCH=386 BUILDPATH=./bin/node-cert-exporter-windows-386.exe make
# Darwin
GOOS=darwin GOARCH=amd64 BUILDPATH=./bin/node-cert-exporter-darwin-amd64 make
GOOS=darwin GOARCH=arm64 BUILDPATH=./bin/node-cert-exporter-darwin-arm64 make
# Freebsd
GOOS=freebsd GOARCH=amd64 BUILDPATH=./bin/node-cert-exporter-freebsd-amd64 make
GOOS=freebsd GOARCH=386 BUILDPATH=./bin/node-cert-exporter-freebsd-386 make
GOOS=freebsd GOARCH=arm BUILDPATH=./bin/node-cert-exporter-freebsd-arm make
- name: Create Release
uses: ncipollo/release-action@v1
with:
draft: true
artifacts: "./bin/*"
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ">=1.21.0"

- name: Build Binaries
run: |
# Linux
GOOS=linux GOARCH=amd64 BUILDPATH=./bin/node-cert-exporter-linux-amd64 make
GOOS=linux GOARCH=arm BUILDPATH=./bin/node-cert-exporter-linux-arm make
GOOS=linux GOARCH=arm64 BUILDPATH=./bin/node-cert-exporter-linux-arm64 make
GOOS=linux GOARCH=386 BUILDPATH=./bin/node-cert-exporter-linux-386 make
# Windows
GOOS=windows GOARCH=amd64 BUILDPATH=./bin/node-cert-exporter-windows-amd64.exe make
GOOS=windows GOARCH=arm BUILDPATH=./bin/node-cert-exporter-windows-arm.exe make
GOOS=windows GOARCH=386 BUILDPATH=./bin/node-cert-exporter-windows-386.exe make
# Darwin
GOOS=darwin GOARCH=amd64 BUILDPATH=./bin/node-cert-exporter-darwin-amd64 make
GOOS=darwin GOARCH=arm64 BUILDPATH=./bin/node-cert-exporter-darwin-arm64 make
# Freebsd
GOOS=freebsd GOARCH=amd64 BUILDPATH=./bin/node-cert-exporter-freebsd-amd64 make
GOOS=freebsd GOARCH=386 BUILDPATH=./bin/node-cert-exporter-freebsd-386 make
GOOS=freebsd GOARCH=arm BUILDPATH=./bin/node-cert-exporter-freebsd-arm make
- name: Create Release
uses: ncipollo/release-action@v1
with:
draft: true
artifacts: "./bin/*"

packages:
if: startsWith(github.ref, 'refs/tags/v')
Expand Down
43 changes: 8 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,45 +47,18 @@ $(INTDIR):
@mkdir -p $@
$(TBIN)/%: | $(TBIN) ; $(info $(M) building $(PACKAGE))
$Q tmp=$$(mktemp -d); \
env GO111MODULE=off GOPATH=$$tmp GOBIN=$(TBIN) $(GO) get $(PACKAGE) \
env GOBIN=$(TBIN) $(GO) install $(PACKAGE) \
|| ret=$$?; \
rm -rf $$tmp ; exit $$ret
#rm -rf $$tmp ; exit $$ret

GOLINT = $(TBIN)/golint
$(BIN)/golint: PACKAGE=golang.org/x/lint/golint

GOCYCLO = $(TBIN)/gocyclo
$(TBIN)/gocyclo: PACKAGE=github.com/fzipp/gocyclo/cmd/gocyclo

INEFFASSIGN = $(TBIN)/ineffassign
$(TBIN)/ineffassign: PACKAGE=github.com/gordonklaus/ineffassign

MISSPELL = $(TBIN)/misspell
$(TBIN)/misspell: PACKAGE=github.com/client9/misspell/cmd/misspell

GOLINT = $(TBIN)/golint
$(TBIN)/golint: PACKAGE=golang.org/x/lint/golint

GOCOV = $(TBIN)/gocov
$(TBIN)/gocov: PACKAGE=github.com/axw/gocov/...
GOCILINT = $(TBIN)/golangci-lint
$(TBIN)/golangci-lint: PACKAGE=github.com/golangci/golangci-lint/cmd/[email protected]

# Tests

.PHONY: lint
lint: | $(GOLINT) ; $(info $(M) running golint) @ ## Runs the golint command
$Q $(GOLINT) -set_exit_status $(PKGS)

.PHONY: gocyclo
gocyclo: | $(GOCYCLO) ; $(info $(M) running gocyclo) @ ## Calculates cyclomatic complexities of functions in Go source code
$Q $(GOCYCLO) -over 25 .

.PHONY: ineffassign
ineffassign: | $(INEFFASSIGN) ; $(info $(M) running ineffassign) @ ## Detects ineffectual assignments in Go code
$Q $(INEFFASSIGN) ./...

.PHONY: misspell
misspell: | $(MISSPELL) ; $(info $(M) running misspell) @ ## Finds commonly misspelled English words
$Q $(MISSPELL) .
lint: | $(GOCILINT) ; $(info $(M) running golangci-lint) @ ## Runs static code analysis using golangci-lint
$Q $(GOCILINT) run --timeout=5m

.PHONY: test
test: ; $(info $(M) running go test) @ ## Runs unit tests
Expand Down Expand Up @@ -117,7 +90,7 @@ checkfmt: ; $(info $(M) running checkfmt) @ ## Checks if code is formatted with
@test "$(shell $(SRC_FILES) gofmt -l)" = "" \
|| { echo "Code not formatted, please run 'make fmt'"; exit 2; }

.PHONY: checkfmt
.PHONY: integration-test
integration-test: | $(INTDIR) docker_build ; $(info $(M) running integration tests) @ ## Run integration tests
mkdir -p ${INTDIR}/ssl
openssl req -new -newkey rsa:1024 -days 365 -nodes -x509 \
Expand Down Expand Up @@ -169,4 +142,4 @@ version: ## Print version information
clean: ; $(info $(M) cleaning) @ ## Cleanup everything
@rm -rfv $(BIN)
@rm -rfv $(TBIN)
@rm -rfv $(CURDIR)/test
@rm -rfv $(CURDIR)/test
8 changes: 4 additions & 4 deletions charts/node-cert-exporter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: node-cert-exporter
description: A Helm chart for node-cert-exporter - An SSL certificate Prometheus exporter
home: https://github.com/amimof/node-cert-exporter
maintainers:
- name: amimof
url: https://github.com/amimof
- name: amimof
url: https://github.com/amimof
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
Expand All @@ -18,11 +18,11 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.1.6
version: 1.1.7

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: "1.1.6"
sources:
- https://github.com/amimof/node-cert-exporter
- https://github.com/amimof/node-cert-exporter
15 changes: 7 additions & 8 deletions charts/node-cert-exporter/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,17 @@ spec:
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
volumeMounts:
- mountPath: /host/etc
name: etc
readOnly: true
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.volumes }}
volumes:
- hostPath:
path: /etc
type: ""
name: etc
{{- toYaml . | nindent 8 }}
{{- end }}
updateStrategy:
type: RollingUpdate
type: RollingUpdate
15 changes: 13 additions & 2 deletions charts/node-cert-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ paths:
- /host/etc/kubernetes/pki/

podAnnotations:
prometheus.io/scrape: 'true'
prometheus.io/port: '9117'
prometheus.io/scrape: "true"
prometheus.io/port: "9117"

tolerations:
# Allow running on masters:
Expand All @@ -30,3 +30,14 @@ resources:
requests:
cpu: 100m
memory: 128Mi

volumes:
- hostPath:
path: /etc
type: ""
name: etc

volumeMounts:
- mountPath: /host/etc
name: etc
readOnly: true

0 comments on commit e0ac2e8

Please sign in to comment.