Skip to content

Commit

Permalink
Add certifier for *.internal-registry.ci.rox.systems (#1005)
Browse files Browse the repository at this point in the history
  • Loading branch information
gavin-stackrox authored Sep 28, 2023
1 parent 9001ef8 commit 4f371fc
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 6 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/build-and-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ jobs:
run: |
make unit-test
- name: Build
- name: Build Infra Server
run: |
make image
- name: Build Certifier
run: |
cd certifier && make image
- name: Login for image push
uses: docker/login-action@v2
with:
Expand All @@ -58,3 +62,4 @@ jobs:
- name: Push
run: |
make push
cd certifier && make push
2 changes: 1 addition & 1 deletion certifier/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM certbot/dns-google:v0.38.0
FROM certbot/dns-google:v2.6.0

COPY certifier /usr/local/bin/certifier

Expand Down
34 changes: 30 additions & 4 deletions certifier/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
.PHONY: build
build:
GOOS=linux GOARCH=amd64 go build -o certifier -ldflags='-s -w' *.go
docker build -t certifier:latest .
.PHONY: all
all: image

TAG=$(shell git describe --tags --abbrev=10 --long)
TAGGED=$(shell git tag --contains | head)
ifneq (,$(TAGGED))
# We're tagged. Use the tag explicitly.
VERSION := $(TAGGED)
else
# We're on a dev/PR branch
VERSION := $(TAG)
endif

.PHONY: tag
tag:
@echo $(VERSION)

IMAGE=us.gcr.io/stackrox-infra/certifier:$(VERSION)
.PHONY: image-name
image-name:
@echo $(IMAGE)

.PHONY: image
image:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o certifier -ldflags='-s -w' *.go
docker build -t $(IMAGE) .

.PHONY: push
push:
docker push $(IMAGE) | cat
6 changes: 6 additions & 0 deletions certifier/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type config struct {
GCSBucket string
GCSPrefix string
GoogleCredentialsFile string
GoogleProject string
RenewalDays int
}

Expand All @@ -47,6 +48,7 @@ func mainCmd() error {
flag.StringVar(&cfg.GCSBucket, "gcs-bucket", "", "")
flag.StringVar(&cfg.GCSPrefix, "gcs-prefix", "", "")
flag.IntVar(&cfg.RenewalDays, "renewal-days", 15, "")
flag.StringVar(&cfg.GoogleProject, "gcp-project-name", "", "")
flag.Parse()

googleCredentialsFile, found := os.LookupEnv("GOOGLE_APPLICATION_CREDENTIALS")
Expand Down Expand Up @@ -165,6 +167,10 @@ func buildCertbotCommand(cfg config) *exec.Cmd {
args = append(args, "--domains", cfg.AlternativeNames)
}

if cfg.GoogleProject != "" {
args = append(args, "--dns-google-project", cfg.GoogleProject)
}

cmd := exec.Command("certbot", args...)
cmd.Stdin = nil
cmd.Stdout = os.Stdout
Expand Down
36 changes: 36 additions & 0 deletions chart/infra-server/templates/demo-certifier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,40 @@ spec:
- name: configuration
secret:
secretName: demo-certifier-credentials

---

apiVersion: batch/v1
kind: CronJob
metadata:
name: demo-certifier-internal-registry-ci-rox-systems
namespace: infra
spec:
schedule: "@weekly"
jobTemplate:
spec:
template:
spec:
containers:
- name: certifier
image: us.gcr.io/stackrox-infra/certifier:0.8.0-11-ga083b2097a
imagePullPolicy: IfNotPresent
args:
- --common-name=*.internal-registry.ci.rox.systems
- --cert-name=internal-registry.ci.rox.systems
- --gcs-bucket=sr-demo-files
- --gcs-prefix=certs
- --gcp-project-name=stackrox-ci
env:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /configuration/google-credentials.json
volumeMounts:
- mountPath: /configuration
name: configuration
readOnly: true
restartPolicy: Never
volumes:
- name: configuration
secret:
secretName: demo-certifier-credentials
{{ end }}

0 comments on commit 4f371fc

Please sign in to comment.