Skip to content

Commit 7be7afd

Browse files
committed
Bind secrets to vcsim for example
Updates examples to use projected secrets so that the basic-auth password and vcenter secrets can be read from the same location. Signed-off-by: Alex Ellis <[email protected]>
1 parent 71c65af commit 7be7afd

File tree

6 files changed

+36
-19
lines changed

6 files changed

+36
-19
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,17 @@ Or use a secret and pass the name:
4444
./vcenter-connector \
4545
-vc-user="" \
4646
-vc-pass="" \
47-
-vc-user-secret-name=vcenter1-username \
48-
-vc-password-secret-name=vcenter1-password
47+
-vc-user-secret-name=vcenter-username \
48+
-vc-password-secret-name=vcenter-password
4949
```
5050

5151
Use `kubectl` to create the secrets you need ahead of time in the namespace where you deploy the connector.
5252

5353
```sh
5454
kubectl create secret generic vcenter-secrets \
55-
--from-literal vcenter1-username=admin \
56-
--from-literal vcenter1-password=test1234
55+
-n openfaas \
56+
--from-literal vcenter-username=user \
57+
--from-literal vcenter-password=pass
5758
```
5859

5960
Now mount your secret at `/var/openfaas/secrets/` in your Kubernetes Deployment YAML file.

contrib/vcsim/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ ENV GOPATH=/root/go/
1010
# Building using -mod=vendor, which will utilize the v
1111
RUN CGO_ENABLED=0 GOOS=linux go build -o vcsim/vcsim vcsim/main.go
1212

13-
FROM alpine:3.8
13+
FROM alpine:3.9
1414

1515
WORKDIR /root/
1616

1717
EXPOSE 8989
18-
COPY --from=builder //root/go/src/github.com/vmware/govmomi/vcsim/vcsim .
18+
COPY --from=builder /root/go/src/github.com/vmware/govmomi/vcsim/vcsim .
1919

2020
CMD ["./vcsim", "-httptest.serve", ":8989", "-tls=false"]

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ func main() {
4343
}
4444

4545
if len(vcUserSecret) > 0 {
46-
val, err := sdk.ReadSecret("vc-secret-user")
46+
val, err := sdk.ReadSecret(vcUserSecret)
4747
if err != nil {
4848
panic(err.Error())
4949
}
5050
vcUser = val
5151
}
5252

5353
if len(vcPasswordSecret) > 0 {
54-
val, err := sdk.ReadSecret("vc-secret-pass")
54+
val, err := sdk.ReadSecret(vcPasswordSecret)
5555
if err != nil {
5656
panic(err.Error())
5757
}

yaml/kubernetes/connector-dep.yml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
apiVersion: extensions/v1beta1
22
kind: Deployment
33
metadata:
4+
name: vcenter-connector
5+
namespace: openfaas
46
labels:
57
app: vcenter
68
component: vcenter-connector
7-
name: vcenter-connector
89
spec:
910
replicas: 1
1011
template:
@@ -15,20 +16,35 @@ spec:
1516
spec:
1617
containers:
1718
- name: vcenter
18-
image: embano1/faas-vcconnector:0.4
19+
image: openfaas/vcenter-connector:0.2.2-rc2
1920
command: ["./connector"]
20-
args: ["-vcenter", "https://vcenter.ip", "-vc-user", "vcuser", "-vc-pass", "vcpass", "-insecure", "-gateway", "http://gateway.openfaas:8080"]
21-
# if you do not have authentication enabled for OpenFaaS comment everything below out (incl. volumes)
21+
args: ["-vcenter", "https://vcsim-server:8989", "-vc-user-secret-name", "vcenter-username", "-vc-pass-secret-name", "vcenter-password", "-insecure", "-gateway", "http://gateway.openfaas:8080"]
22+
# To remove auth, remove the volumes and mounts.
2223
env:
2324
- name: basic_auth
2425
value: "true"
2526
- name: secret_mount_path
2627
value: "/var/secrets/"
2728
volumeMounts:
28-
- name: gateway-basic-auth
29+
- name: auth-secrets-projected
2930
readOnly: true
3031
mountPath: "/var/secrets/"
3132
volumes:
32-
- name: gateway-basic-auth
33-
secret:
34-
secretName: gateway-basic-auth
33+
- name: auth-secrets-projected
34+
projected:
35+
defaultMode: 420
36+
sources:
37+
- secret:
38+
items:
39+
- key: basic-auth-user
40+
path: basic-auth-user
41+
- key: basic-auth-password
42+
path: basic-auth-password
43+
name: basic-auth
44+
- secret:
45+
items:
46+
- key: vcenter-username
47+
path: vcenter-username
48+
- key: vcenter-password
49+
path: vcenter-password
50+
name: vcenter-secrets

yaml/kubernetes/vcsim-server-dep.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
apiVersion: extensions/v1beta1
22
kind: Deployment
33
metadata:
4+
name: vcsim-server
5+
namespace: openfaas
46
labels:
57
app: vcsim
68
component: vcsim-server
7-
name: vcsim-server
8-
namespace: openfaas
99
spec:
1010
replicas: 1
1111
template:

yaml/kubernetes/vcsim-server-svc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ apiVersion: v1
22
kind: Service
33
metadata:
44
name: vcsim
5+
namespace: openfaas
56
labels:
67
app: vcsim
78
component: vcsim-server
8-
namespace: openfaas
99
spec:
1010
ports:
1111
- port: 8989

0 commit comments

Comments
 (0)