Skip to content

Commit

Permalink
chore: switch to using multi-os image, update docs
Browse files Browse the repository at this point in the history
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
  • Loading branch information
aramase committed Mar 1, 2021
1 parent 0253083 commit 89a7d0a
Show file tree
Hide file tree
Showing 26 changed files with 159 additions and 134 deletions.
19 changes: 11 additions & 8 deletions docs/sample/ingress-controller-tls/deployment-app-one.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-one
name: busybox-one
labels:
app: nginx-one
app: busybox-one
spec:
replicas: 1
selector:
matchLabels:
app: nginx-one
app: busybox-one
template:
metadata:
labels:
app: nginx-one
app: busybox-one
spec:
containers:
- image: nginx
name: nginx
- name: busybox
image: k8s.gcr.io/e2e-test-images/busybox:1.29
command:
- "/bin/sh"
- "10000"
volumeMounts:
- name: secrets-store-inline
mountPath: "/mnt/secrets-store"
Expand All @@ -34,10 +37,10 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: nginx-one
name: busybox-one
spec:
type: ClusterIP
ports:
- port: 80
selector:
app: nginx-one
app: busybox-one
19 changes: 11 additions & 8 deletions docs/sample/ingress-controller-tls/deployment-app-two.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-two
name: busybox-two
labels:
app: nginx-two
app: busybox-two
spec:
replicas: 1
selector:
matchLabels:
app: nginx-two
app: busybox-two
template:
metadata:
labels:
app: nginx-two
app: busybox-two
spec:
containers:
- image: nginx
name: nginx
- name: busybox
image: k8s.gcr.io/e2e-test-images/busybox:1.29
command:
- "/bin/sh"
- "10000"
volumeMounts:
- name: secrets-store-inline
mountPath: "/mnt/secrets-store"
Expand All @@ -34,10 +37,10 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: nginx-two
name: busybox-two
spec:
type: ClusterIP
ports:
- port: 80
selector:
app: nginx-two
app: busybox-two
14 changes: 9 additions & 5 deletions docs/sample/ingress-controller-tls/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: extensions/v1beta1
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-tls
Expand All @@ -15,10 +15,14 @@ spec:
http:
paths:
- backend:
serviceName: nginx-one
servicePort: 80
service:
name: busybox-one
port:
number: 80
path: /(.*)
- backend:
serviceName: nginx-two
servicePort: 80
service:
name: busybox-two
port:
number: 80
path: /two(/|$)(.*)
26 changes: 12 additions & 14 deletions examples/kind/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@

## Prerequisite

- Follow [instructions](https://github.com/kubernetes-sigs/kind#installation-and-usage) to setup kind in your machine
- Follow [instructions](https://github.com/kubernetes-sigs/kind#installation-and-usage) to set up kind in your machine

> Windows 10 users can use WSL 2 to install kind. Integrate docker for windows with WSL 2 by following the [instructions](https://kind.sigs.k8s.io/docs/user/using-wsl2/)..
> Windows 10 users can use WSL 2 to install kind. Integrate docker for windows with WSL 2 by following the [instructions](https://kind.sigs.k8s.io/docs/user/using-wsl2/).
## Setup

- Follow the [instructions](https://github.com/Azure/secrets-store-csi-driver-provider-azure/blob/master/docs/service-principal-mode.md) to setup Service Principal and give it access to Azure Key Vault. Keep `ClientID` and `ClientSecret` of the Service Principal handy.
- Follow the [instructions](https://azure.github.io/secrets-store-csi-driver-provider-azure/configurations/identity-access-modes/service-principal-mode/) to set up Service Principal and give it access to Azure Key Vault. Keep `ClientID` and `ClientSecret` of the Service Principal handy.

- Copy [v1alpha1_secretproviderclass.yaml](https://github.com/Azure/secrets-store-csi-driver-provider-azure/blob/master/examples/v1alpha1_secretproviderclass.yaml) and [nginx-pod-secrets-store-inline-volume-secretproviderclass.yaml](https://github.com/Azure/secrets-store-csi-driver-provider-azure/blob/master/examples/nginx-pod-secrets-store-inline-volume-secretproviderclass.yaml) to this directory.
- Copy [v1alpha1_secretproviderclass.yaml](https://raw.githubusercontent.com/Azure/secrets-store-csi-driver-provider-azure/master/examples/service-principal/v1alpha1_secretproviderclass_service_principal.yaml) and [pod-secrets-store-inline-volume-secretproviderclass.yaml](https://raw.githubusercontent.com/Azure/secrets-store-csi-driver-provider-azure/master/examples/service-principal/pod-secrets-store-inline-volume-secretproviderclass.yaml) to this directory.

- Update `v1alpha1_secretproviderclass.yaml` to provide keyvault name and the keyvault resources to fetch.
- Update `v1alpha1_secretproviderclass.yaml` to provide keyvault name and keyvault resources to fetch.

```yaml
cloudName: 'AzurePublicCloud' # [OPTIONAL available for version > 0.0.4] if not provided, azure environment will default to AzurePublicCloud
keyvaultName: '' # the name of the KeyVault
keyvaultName: '' # the name of the KeyVault
objects: |
array:
- |
Expand All @@ -29,9 +29,7 @@ objects: |
objectName: key1
objectType: key
objectVersion: ""
resourceGroup: '' # [REQUIRED for version < 0.0.4] the resource group of the KeyVault
subscriptionId: '' # [REQUIRED for version < 0.0.4] the subscription ID of the KeyVault
tenantId: '' # the tenant ID of the KeyVault
tenantId: '<tenant id>' # the tenant ID of the KeyVault
```

## Usage
Expand All @@ -52,24 +50,24 @@ The final output would contain the list of keys and secrets pulled from the keyv
kind create cluster --name kind-csi-demo
```

- Install [csi-secrets-store-provider-azure](https://github.com/Azure/secrets-store-csi-driver-provider-azure#install-the-secrets-store-csi-driver-and-the-azure-keyvault-provider)
- Install [csi-secrets-store-provider-azure](https://azure.github.io/secrets-store-csi-driver-provider-azure/getting-started/installation/)

- Add your Service Principal credentials as a Kubernetes secrets accessible by the Secrets Store CSI driver.

```sh
kubectl create secret generic secrets-store-creds --from-literal clientid=<CLIENTID> --from-literal clientsecret=<CLIENTSECRET>
```

- Deploy the app. This will deploy a nginx container and mount the secrets as volume at path `/mnt/secrets-store`
- Deploy the app. This will deploy a busybox container and mount the secrets as volume at path `/mnt/secrets-store`

```sh
kubectl apply -f nginx-pod-secrets-store-inline-volume.yaml
kubectl apply -f pod-secrets-store-inline-volume.yaml
```

### Validate the secret

Run the below command and it should list the secrets pulled from keyvault. Each of the file contains the value of the secret.
Run the below command to list the secrets pulled from keyvault. Each of the file contains the value of the secret.

```sh
kubectl exec -it nginx-secrets-store-inline ls /mnt/secrets-store/
kubectl exec busybox-secrets-store-inline ls /mnt/secrets-store/
```
6 changes: 3 additions & 3 deletions examples/kind/kind-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ kubectl create secret generic secrets-store-creds --from-literal clientid=$CLIEN

# Deploy app
kubectl apply -f v1alpha1_secretproviderclass.yaml
kubectl apply -f nginx-pod-secrets-store-inline-volume-secretproviderclass.yaml
kubectl apply -f pod-secrets-store-inline-volume-secretproviderclass.yaml

# wait for deployment
kubectl wait --for=condition=ready pods/nginx-secrets-store-inline --timeout=300s
kubectl wait --for=condition=ready pods/busybox-secrets-store-inline --timeout=300s

# validate
kubectl exec -it nginx-secrets-store-inline ls /mnt/secrets-store/
kubectl exec busybox-secrets-store-inline ls /mnt/secrets-store/
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
kind: Pod
apiVersion: v1
metadata:
name: nginx-secrets-store-inline-podid
name: busybox-secrets-store-inline-podid
labels:
aadpodidbinding: "demo" # Set the label value to the selector defined in AzureIdentityBinding
spec:
containers:
- name: nginx
image: nginx
- name: busybox
image: k8s.gcr.io/e2e-test-images/busybox:1.29
command:
- "/bin/sh"
- "10000"
volumeMounts:
- name: secrets-store01-inline
mountPath: "/mnt/secrets-store"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
kind: Pod
apiVersion: v1
metadata:
name: nginx-secrets-store-inline
name: busybox-secrets-store-inline
spec:
containers:
- image: nginx
name: nginx
- name: busybox
image: k8s.gcr.io/e2e-test-images/busybox:1.29
command:
- "/bin/sh"
- "10000"
volumeMounts:
- name: secrets-store-inline
mountPath: "/mnt/secrets-store"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
name: busybox-deployment
labels:
app: nginx
app: busybox
spec:
replicas: 1
selector:
matchLabels:
app: nginx
app: busybox
template:
metadata:
labels:
app: nginx
app: busybox
spec:
terminationGracePeriodSeconds: 0
containers:
- image: nginx
name: nginx
- name: busybox
image: k8s.gcr.io/e2e-test-images/busybox:1.29
command:
- "/bin/sh"
- "10000"
env:
- name: SECRET_USERNAME
valueFrom:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
kind: Pod
apiVersion: v1
metadata:
name: nginx-secrets-store-inline-system-msi
name: busybox-secrets-store-inline-system-msi
spec:
containers:
- name: nginx
image: nginx
- name: busybox
image: k8s.gcr.io/e2e-test-images/busybox:1.29
command:
- "/bin/sh"
- "10000"
volumeMounts:
- name: secrets-store01-inline
mountPath: "/mnt/secrets-store"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
kind: Pod
apiVersion: v1
metadata:
name: nginx-secrets-store-inline-user-msi
name: busybox-secrets-store-inline-user-msi
spec:
containers:
- name: nginx
image: nginx
- name: busybox
image: k8s.gcr.io/e2e-test-images/busybox:1.29
command:
- "/bin/sh"
- "10000"
volumeMounts:
- name: secrets-store01-inline
mountPath: "/mnt/secrets-store"
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/auto_rotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ var _ = Describe("Test auto rotation of mount contents and K8s secrets", func()
p = pod.Create(pod.CreateInput{
Creator: kubeClient,
Config: config,
Name: "nginx-secrets-store-inline",
Name: "busybox-secrets-store-inline",
Namespace: ns.Name,
SecretProviderClassName: spc.Name,
NodePublishSecretRefName: nodePublishSecretRef.Name,
Expand Down Expand Up @@ -245,7 +245,7 @@ var _ = Describe("Test auto rotation of mount contents and K8s secrets", func()
p = pod.Create(pod.CreateInput{
Creator: kubeClient,
Config: config,
Name: "nginx-secrets-store-inline",
Name: "busybox-secrets-store-inline",
Namespace: ns.Name,
SecretProviderClassName: spc.Name,
})
Expand Down Expand Up @@ -423,7 +423,7 @@ var _ = Describe("Test auto rotation of mount contents and K8s secrets", func()
p = pod.Create(pod.CreateInput{
Creator: kubeClient,
Config: config,
Name: "nginx-secrets-store-inline",
Name: "busybox-secrets-store-inline",
Namespace: ns.Name,
SecretProviderClassName: spc.Name,
Labels: map[string]string{"aadpodidbinding": ns.Name},
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/certificates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ var _ = Describe("When fetching certificates and private key from Key Vault", fu
p = pod.Create(pod.CreateInput{
Creator: kubeClient,
Config: config,
Name: "nginx-secrets-store-inline-crd-certs",
Name: "busybox-secrets-store-inline-crd-certs",
Namespace: ns.Name,
SecretProviderClassName: spc.Name,
NodePublishSecretRefName: nodePublishSecretRef.Name,
Expand Down
5 changes: 2 additions & 3 deletions test/e2e/framework/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ func Create(input CreateInput) *corev1.Pod {
Containers: []corev1.Container{
{
Name: "tester",
Image: "nginx",
Image: "k8s.gcr.io/e2e-test-images/busybox:1.29",
ImagePullPolicy: corev1.PullIfNotPresent,
Command: []string{"/bin/sleep", "10000"},
VolumeMounts: []corev1.VolumeMount{
{
Name: "secrets-store-inline",
Expand Down Expand Up @@ -103,8 +104,6 @@ func Create(input CreateInput) *corev1.Pod {
}

if input.Config.IsWindowsTest {
pod.Spec.Containers[0].Image = "e2eteam/busybox:1.29"
pod.Spec.Containers[0].Command = []string{"powershell.exe", "-Command", "while (1) { sleep 1}"}
pod.Spec.NodeSelector = map[string]string{"kubernetes.io/os": "windows"}
} else {
pod.Spec.NodeSelector = map[string]string{"kubernetes.io/os": "linux"}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ var _ = Describe("When deploying SecretProviderClass CRD with keys", func() {
p = pod.Create(pod.CreateInput{
Creator: kubeClient,
Config: config,
Name: "nginx-secrets-store-inline-crd",
Name: "busybox-secrets-store-inline-crd",
Namespace: ns.Name,
SecretProviderClassName: spc.Name,
NodePublishSecretRefName: nodePublishSecretRef.Name,
Expand Down

0 comments on commit 89a7d0a

Please sign in to comment.