Skip to content

Commit 59ef46c

Browse files
committed
feat: remove cert manager
1 parent aa06443 commit 59ef46c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+6683
-511
lines changed

.github/workflows/agent-ci.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,14 @@ jobs:
9898
apt-get update && apt-get install -y make git jq
9999
cd agent
100100
# if this is a tag build, use the tag as the version, otherwise use the sha
101-
TAGS="-t ${REGISTRY@L}/${{env.IMAGE_NAME}}/agent:${{ github.sha }}"
101+
git fetch --all
102+
export GIT_SHA=$(git rev-parse --short ${{ github.sha }})
103+
TAGS="-t ${REGISTRY@L}/${{env.IMAGE_NAME}}/agent:${GIT_SHA}"
102104
case ${{ github.ref_type }} in
103105
branch)
104106
# The last tag + current git sha
105-
export AGENT_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0")+${{ github.sha }}
107+
export AGENT_VERSION=$(git tag --list 'agent*' --sort=-v:refname | head -n 1 | cut -d/ -f2 || echo "0.0.0")+${GIT_SHA}
108+
TAGS="$TAGS -t ${REGISTRY@L}/${{env.IMAGE_NAME}}/agent:$(echo "${AGENT_VERSION}" | tr + -)"
106109
;;
107110
tag)
108111
# The version part of the tag

.github/workflows/operator-ci.yaml

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,6 @@ env:
5454

5555
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
5656
jobs:
57-
## move it all down to the tests job, should do all the tests then, and not double install stuff
58-
# unit-test:
59-
# runs-on: ubuntu-latest
60-
# steps:
61-
# - uses: actions/checkout@v4
62-
# - name: Setup Go 1.23
63-
# uses: actions/setup-go@v5
64-
# with:
65-
# go-version: 1.23
66-
# - name: Unit tests
67-
# run: |
68-
# cd operator
69-
# make unit-tests
7057
tests:
7158
runs-on: ubuntu-latest
7259
steps:
@@ -78,6 +65,7 @@ jobs:
7865
uses: actions/setup-go@v5
7966
with:
8067
go-version: 1.23
68+
cache-dependency-path: operator/go.sum
8169
- name: Log in to the Container registry
8270
uses: docker/login-action@v3
8371
with:
@@ -90,6 +78,29 @@ jobs:
9078
with:
9179
version: v0.26.0
9280
install_only: true
81+
- name: Restore cached Binaries
82+
id: cached-binaries
83+
uses: actions/cache/restore@v4
84+
with:
85+
key: ${{ runner.os }}-${{ runner.arch }}-bin-${{ hashFiles('operator/deps.mk') }}
86+
restore-keys: ${{ runner.os }}-${{ runner.arch }}-bin-
87+
path: |
88+
${{ github.workspace }}/operator/bin
89+
~/.cache/go-build
90+
- name: Install dependencies
91+
if: steps.cached-binaries.outputs.cache-hit != 'true'
92+
run: |
93+
cd operator
94+
make install-deps
95+
- name: Save cached Binaries
96+
id: save-cached-binaries
97+
if: steps.cached-binaries.outputs.cache-hit != 'true'
98+
uses: actions/cache/save@v4
99+
with:
100+
key: ${{ runner.os }}-${{ runner.arch }}-bin-${{ hashFiles('operator/deps.mk') }}
101+
path: |
102+
${{ github.workspace }}/operator/bin
103+
~/.cache/go-build
93104
- name: end-to-end-tests
94105
run: |
95106
cd operator
@@ -131,11 +142,14 @@ jobs:
131142
apt-get update && apt-get install -y make git jq
132143
cd operator
133144
# if this is a tag build, use the tag as the version, otherwise use the sha
134-
TAGS="-t ${REGISTRY@L}/${{env.IMAGE_NAME}}/operator:${{ github.sha }}"
145+
git fetch --all
146+
export GIT_SHA=$(git rev-parse --short ${{ github.sha }})
147+
TAGS="-t ${REGISTRY@L}/${{env.IMAGE_NAME}}/operator:${GIT_SHA}"
135148
case ${{ github.ref_type }} in
136149
branch)
137150
# The last tag + current git sha
138-
export OPERATOR_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0")+${{ github.sha }}
151+
export OPERATOR_VERSION=$(git tag --list 'operator*' --sort=-v:refname | head -n 1 | cut -d/ -f2 || echo "0.0.0")+${GIT_SHA}
152+
TAGS="$TAGS -t ${REGISTRY@L}/${{env.IMAGE_NAME}}/operator:$(echo "${OPERATOR_VERSION}" | tr + -)"
139153
;;
140154
tag)
141155
# The version part of the tag
@@ -149,7 +163,7 @@ jobs:
149163
esac
150164
set -x
151165
docker buildx build \
152-
--build-arg GIT_SHA=$${{ github.sha }} \
166+
--build-arg GIT_SHA=${GIT_SHA} \
153167
--build-arg VERSION=${OPERATOR_VERSION} \
154168
--build-arg GO_VERSION=${GO_VERSION} \
155169
--push \

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.cursorignore
22
.pytest_cache
3-
.idea
3+
.idea
4+
**/err.txt

.vscode/launch.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"request": "launch",
1111
"mode": "debug",
1212
"program": "${workspaceRoot}/operator/cmd/main.go",
13+
"cwd": "${workspaceRoot}/operator",
1314
"buildFlags": "--ldflags '-X github.com/NVIDIA/skyhook/internal/version.GIT_SHA=foobars -X github.com/NVIDIA/skyhook/internal/version.VERSION=v0.5.0'",
1415
"env": {
1516
"ENABLE_WEBHOOKS": "false",

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ There are a few pre-built generalist packages available at [NVIDIA/skyhook-packa
5050
## Quick Start
5151

5252
### Install the operator
53-
1. Install cert-manager `kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.15.2/cert-manager.yaml`
5453
1. Create a secret for the operator to pull images `kubectl create secret generic node-init-secret --from-file=.dockerconfigjson=${HOME}/.config/containers/auth.json --type=kubernetes.io/dockerconfigjson -n skyhook`
5554
1. Install the operator `helm install skyhook ./chart --namespace skyhook`
5655

agent/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,14 @@ docker-setup:
5656
$(DOCKER_CMD) buildx create --platform linux/amd64,linux/arm64 --use builder
5757
$(DOCKER_CMD) run --privileged --rm tonistiigi/binfmt --install amd64,arm64
5858

59-
ACTUAL_TAGS=$(shell echo "-t $(REGISTRY)/$(AGENT_IMAGE):$(shell date +%y.%m.%d-%H%M%S)-$(COMMIT_SHORT_SHA) $(TAGS)" | tr A-Z a-z)
59+
GIT_SHA=$(shell git rev-parse --short HEAD)
60+
ACTUAL_TAGS=$(shell echo "-t $(REGISTRY)/$(AGENT_IMAGE):$(shell date +%y.%m.%d-%H%M%S)-$(GIT_SHA) $(TAGS)" | tr A-Z a-z)
6061
.PHONY: docker-build-only
6162
docker-build-only:
6263
@echo "Building skyhook-agent $(DOCKER_CMD) image with tags: $(ACTUAL_TAGS)"
63-
$(DOCKER_CMD) buildx build $(BUILD_ARGS) --build-arg AGENT_VERSION=$(AGENT_VERSION) --platform linux/amd64,linux/arm64 $(ACTUAL_TAGS) --metadata-file=metadata.json -f ../containers/agent.Dockerfile .
64+
$(DOCKER_CMD) buildx build $(BUILD_ARGS) --build-arg AGENT_VERSION=$(AGENT_VERSION) \
65+
--build-arg GIT_SHA=$(GIT_SHA) \
66+
--platform linux/amd64,linux/arm64 $(ACTUAL_TAGS) --metadata-file=metadata.json -f ../containers/agent.Dockerfile .
6467

6568
##@ Vendor
6669
.PHONY: vendor

chart/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Settings | Description | Default |
2323
| controllerManager.tolerations | add tolerations to the controller manager pod | [] |
2424
| controllerManager.selectors | add node selectors to the controller manager pod | {} |
2525
| controllerManager.manager.env.copyDirRoot | Directory for which the operator will work from on the host. Some environments may require this to be set to a specific directory. | /tmp |
26-
| controllerManager.manager.env.enableWebhooks | Enable the webhook setup in the operator controller. Default is "true" and is required for production. | "true" |
26+
| webhooks.enable | Enable the webhook setup in the operator controller. Default is "true" and is required for production. | "true" |
2727
| controllerManager.manager.env.leaderElection | Enable leader election for the operator controller. Default is "true" and is required for production. | "true" |
2828
| controllerManager.manager.env.logLevel | Log level for the operator controller. If you want more or less logs, change this value to "debug" or "error". | "info" |
2929
| controllerManager.manager.env.reapplyOnReboot | Reapply the packages on reboot. This is useful for systems that are read-only. | "false" |
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{{- if .Values.webhook.enable }}
2+
apiVersion: batch/v1
3+
kind: Job
4+
metadata:
5+
name: "{{ include "chart.fullname" . }}-webhook-cleanup"
6+
annotations:
7+
"helm.sh/hook": pre-delete
8+
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
9+
spec:
10+
template:
11+
spec:
12+
restartPolicy: Never
13+
serviceAccountName: {{ include "chart.fullname" . }}-controller-manager
14+
containers:
15+
- name: cleanup
16+
image: {{ .Values.webhook.removalImage | default "bitnami/kubectl" }}:{{ .Values.webhook.removalTag | default "latest" }}
17+
command:
18+
- /bin/sh
19+
- -c
20+
- |
21+
NAMESPACE="{{ .Release.Namespace }}"
22+
WEBHOOK_SECRET_NAME="{{ .Values.webhook.secretName | default "webhook-cert" }}"
23+
VALIDATING_WEBHOOK_CONFIGURATION_NAME="skyhook-operator-validating-webhook"
24+
MUTATING_WEBHOOK_CONFIGURATION_NAME="skyhook-operator-mutating-webhook"
25+
kubectl delete secret -n $NAMESPACE $WEBHOOK_SECRET_NAME || true
26+
kubectl delete validatingwebhookconfiguration $VALIDATING_WEBHOOK_CONFIGURATION_NAME || true
27+
kubectl delete mutatingwebhookconfiguration $MUTATING_WEBHOOK_CONFIGURATION_NAME || true
28+
{{- end }}

chart/templates/deployment.yaml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ spec:
6262
- name: LOG_LEVEL
6363
value: {{ quote .Values.controllerManager.manager.env.logLevel }}
6464
- name: ENABLE_WEBHOOKS
65-
value: {{ quote .Values.controllerManager.manager.env.enableWebhooks }}
65+
value: {{ quote .Values.webhook.enable }}
6666
- name: NAMESPACE
6767
value: {{ .Release.Namespace }}
6868
- name: IMAGE_PULL_SECRET
@@ -97,7 +97,10 @@ spec:
9797
path: /readyz
9898
port: 8081
9999
initialDelaySeconds: 5
100-
periodSeconds: 10
100+
periodSeconds: 20
101+
successThreshold: 1
102+
failureThreshold: 2
103+
timeoutSeconds: 3
101104
resources: {{ if .Values.controllerManager.manager.resources }}{{- toYaml .Values.controllerManager.manager.resources | nindent 10 }}{{ else }}
102105
limits:
103106
cpu: {{ maxf 1000 (mulf 1.6 .Values.estimatedNodeCount (maxf 1 (mulf 0.4 .Values.estimatedPackageCount))) | int }}m
@@ -108,10 +111,6 @@ spec:
108111
{{- end }}
109112
securityContext: {{- toYaml .Values.controllerManager.manager.containerSecurityContext
110113
| nindent 10 }}
111-
volumeMounts:
112-
- mountPath: /tmp/k8s-webhook-server/serving-certs
113-
name: cert
114-
readOnly: true
115114
- args: {{- toYaml .Values.controllerManager.kubeRbacProxy.args | nindent 8 }}
116115
env:
117116
- name: KUBERNETES_CLUSTER_DOMAIN
@@ -132,11 +131,6 @@ spec:
132131
runAsNonRoot: true
133132
serviceAccountName: {{ include "chart.fullname" . }}-controller-manager
134133
terminationGracePeriodSeconds: 10
135-
volumes:
136-
- name: cert
137-
secret:
138-
defaultMode: 420
139-
secretName: webhook-server-cert
140134
{{ if ((.Values.controllerManager.podDisruptionBudget).minAvailable) }}
141135
{{ if ge .Values.controllerManager.podDisruptionBudget.minAvailable .Values.controllerManager.replicas }}
142136
{{- $_ := required "minAvailable to be less than replicas" .nil }}

chart/templates/manager-rbac.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ metadata:
55
labels:
66
{{- include "chart.labels" . | nindent 4 }}
77
rules:
8+
- apiGroups:
9+
- admissionregistration.k8s.io
10+
resources:
11+
- mutatingwebhookconfigurations
12+
- validatingwebhookconfigurations
13+
verbs:
14+
- create
15+
- delete
16+
- get
17+
- list
18+
- patch
19+
- update
20+
- watch
821
- apiGroups:
922
- ""
1023
resources:
@@ -66,6 +79,18 @@ rules:
6679
- pods/status
6780
verbs:
6881
- get
82+
- apiGroups:
83+
- ""
84+
resources:
85+
- secrets
86+
verbs:
87+
- create
88+
- delete
89+
- get
90+
- list
91+
- patch
92+
- update
93+
- watch
6994
- apiGroups:
7095
- skyhook.nvidia.com
7196
resources:

0 commit comments

Comments
 (0)