Skip to content

Commit feeb21a

Browse files
simcodvknabel
andauthored
Use Metal-Edit user for HMAC (#69)
Co-authored-by: Valentin Knabel <dev@vknabel.com>
1 parent cf3b482 commit feeb21a

File tree

7 files changed

+29
-5
lines changed

7 files changed

+29
-5
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ endif
167167

168168
# this is configured to work with the capi-lab
169169
export METAL_API_URL := "http://metal.203.0.113.1.nip.io:8080"
170-
export METAL_API_HMAC := "metal-admin"
170+
export METAL_API_HMAC := "metal-edit"
171+
export METAL_API_HMAC_AUTH_TYPE := "Metal-Edit"
171172

172173
.PHONY: install
173174
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Now, you are able to install the CAPMS into your management cluster:
4141
# export the following environment variables
4242
export METAL_API_URL=<url>
4343
export METAL_API_HMAC=<hmac>
44+
export METAL_API_HMAC_AUTH_TYPE=<Metal-Admin or Metal-Edit>
4445
export EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION=true
4546

4647
# initialize the management cluster

capi-lab/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ KUBECONFIG := $(shell pwd)/mini-lab/.kubeconfig
77
MINI_LAB_FLAVOR=capms
88

99
METAL_API_URL=http://metal.203.0.113.1.nip.io:8080
10-
METAL_API_HMAC=metal-admin
10+
METAL_API_HMAC=metal-edit
11+
METAL_API_HMAC_AUTH_TYPE=Metal-Edit
1112
METALCTL_API_URL=http://metal.203.0.113.1.nip.io:8080
12-
METALCTL_HMAC=metal-admin
13+
METALCTL_HMAC=metal-edit
14+
METALCTL_HMAC_AUTH_TYPE=Metal-Edit
1315

1416
METAL_PARTITION ?= mini-lab
1517
METAL_PROJECT_ID ?= 00000000-0000-0000-0000-000000000001

capi-lab/metal-ccm.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ metadata:
77
stringData:
88
api-url: ${METAL_API_URL}
99
api-hmac: ${METAL_API_HMAC}
10+
api-hmac-auth-type: ${METAL_API_HMAC_AUTH_TYPE}
1011
---
1112
apiVersion: v1
1213
kind: ServiceAccount
@@ -172,6 +173,11 @@ spec:
172173
secretKeyRef:
173174
key: api-hmac
174175
name: cloud-controller-manager
176+
- name: METAL_AUTH_HMAC_AUTH_TYPE
177+
valueFrom:
178+
secretKeyRef:
179+
key: api-hmac-auth-type
180+
name: cloud-controller-manager
175181
- name: METAL_PROJECT_ID
176182
value: 00000000-0000-0000-0000-000000000001
177183
- name: METAL_PARTITION_ID
@@ -185,7 +191,7 @@ spec:
185191
value: internet-mini-lab,${METAL_NODE_NETWORK_ID}
186192
- name: METAL_SSH_PUBLICKEY
187193
value: ""
188-
image: ghcr.io/metal-stack/metal-ccm:v0.9.3
194+
image: ghcr.io/metal-stack/metal-ccm:v0.9.4
189195
imagePullPolicy: IfNotPresent
190196
livenessProbe:
191197
failureThreshold: 2

cmd/main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,5 +202,10 @@ func newMetalClient() (metalgo.Client, error) {
202202
return nil, errors.New("METAL_API_HMAC environment variable must be set")
203203
}
204204

205-
return metalgo.NewDriver(url, "", hmac)
205+
hmacAuthType := os.Getenv("METAL_API_HMAC_AUTH_TYPE")
206+
if hmacAuthType == "" {
207+
return nil, errors.New("METAL_API_HMAC_AUTH_TYPE environment variable must be set")
208+
}
209+
210+
return metalgo.NewDriver(url, "", hmac, metalgo.AuthType(hmacAuthType))
206211
}

config/manager/manager.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ metadata:
66
stringData:
77
api-url: ${METAL_API_URL}
88
api-hmac: ${METAL_API_HMAC}
9+
api-hmac-auth-type: ${METAL_API_HMAC_AUTH_TYPE}
910
---
1011
apiVersion: apps/v1
1112
kind: Deployment
@@ -44,6 +45,11 @@ spec:
4445
secretKeyRef:
4546
name: controller-manager-config
4647
key: api-hmac
48+
- name: METAL_API_HMAC_AUTH_TYPE
49+
valueFrom:
50+
secretKeyRef:
51+
name: controller-manager-config
52+
key: api-hmac-auth-type
4753
command:
4854
- /manager
4955
args:

metadata.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# update this file only when a new major or minor version is released
66
apiVersion: clusterctl.cluster.x-k8s.io/v1alpha3
77
releaseSeries:
8+
- major: 0
9+
minor: 3
10+
contract: v1beta1
811
- major: 0
912
minor: 2
1013
contract: v1beta1

0 commit comments

Comments
 (0)