Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
add secrets-store-csi-driver addon
Browse files Browse the repository at this point in the history
  • Loading branch information
aramase committed Mar 19, 2020
1 parent 13e72f2 commit 4bb8eb4
Show file tree
Hide file tree
Showing 11 changed files with 787 additions and 140 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
apiVersion: storage.k8s.io/v1beta1
kind: CSIDriver
metadata:
name: secrets-store.csi.k8s.io
spec:
podInfoOnMount: true
attachRequired: false
volumeLifecycleModes:
- Ephemeral
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: secrets-store-csi-driver
namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: secretproviderclasses-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: secretproviderclasses-role
subjects:
- kind: ServiceAccount
name: secrets-store-csi-driver
namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: secretproviderclasses-role
rules:
- apiGroups:
- secrets-store.csi.x-k8s.io
resources:
- secretproviderclasses
verbs:
- get
- list
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: secretproviderclasses.secrets-store.csi.x-k8s.io
spec:
group: secrets-store.csi.x-k8s.io
names:
kind: SecretProviderClass
listKind: SecretProviderClassList
plural: secretproviderclasses
singular: secretproviderclass
scope: ""
validation:
openAPIV3Schema:
description: SecretProviderClass is the Schema for the secretproviderclasses
API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: SecretProviderClassSpec defines the desired state of SecretProviderClass
properties:
parameters:
additionalProperties:
type: string
description: Configuration for specific provider
type: object
provider:
description: Configuration for provider name
type: string
type: object
status:
description: SecretProviderClassStatus defines the observed state of SecretProviderClass
type: object
type: object
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
---
kind: DaemonSet
apiVersion: apps/v1
metadata:
name: csi-secrets-store
spec:
selector:
matchLabels:
app: csi-secrets-store
template:
metadata:
labels:
app: csi-secrets-store
spec:
serviceAccountName: secrets-store-csi-driver
hostNetwork: true
containers:
- name: node-driver-registrar
image: {{ContainerImage "csi-node-driver-registrar"}}
args:
- --v=5
- --csi-address=/csi/csi.sock
- --kubelet-registration-path=/var/lib/kubelet/plugins/csi-secrets-store/csi.sock
lifecycle:
preStop:
exec:
command:
[
"/bin/sh",
"-c",
"rm -rf /registration/secrets-store.csi.k8s.io-reg.sock",
]
env:
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
imagePullPolicy: Always
volumeMounts:
- name: plugin-dir
mountPath: /csi
- name: registration-dir
mountPath: /registration
- name: secrets-store
image: {{ContainerImage "csi-secrets-store"}}
args:
- "--debug=true"
- "--endpoint=$(CSI_ENDPOINT)"
- "--nodeid=$(KUBE_NODE_NAME)"
- "--provider-volume=/etc/kubernetes/secrets-store-csi-providers"
env:
- name: CSI_ENDPOINT
value: unix:///csi/csi.sock
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
imagePullPolicy: Always
securityContext:
privileged: true
ports:
- containerPort: 9808
name: healthz
protocol: TCP
livenessProbe:
failureThreshold: 5
httpGet:
path: /healthz
port: healthz
initialDelaySeconds: 30
timeoutSeconds: 10
periodSeconds: 15
volumeMounts:
- name: plugin-dir
mountPath: /csi
- name: mountpoint-dir
mountPath: /var/lib/kubelet/pods
mountPropagation: Bidirectional
- name: providers-dir
mountPath: /etc/kubernetes/secrets-store-csi-providers
- name: liveness-probe
image: {{ContainerImage "livenessprobe"}}
imagePullPolicy: Always
args:
- --csi-address=/csi/csi.sock
- --probe-timeout=3s
- --health-port=9808
volumeMounts:
- name: plugin-dir
mountPath: /csi
volumes:
- name: mountpoint-dir
hostPath:
path: /var/lib/kubelet/pods
type: DirectoryOrCreate
- name: registration-dir
hostPath:
path: /var/lib/kubelet/plugins_registry/
type: Directory
- name: plugin-dir
hostPath:
path: /var/lib/kubelet/plugins/csi-secrets-store/
type: DirectoryOrCreate
- name: providers-dir
hostPath:
path: /etc/kubernetes/secrets-store-csi-providers
type: DirectoryOrCreate
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
labels:
app: csi-secrets-store-provider-azure
name: csi-secrets-store-provider-azure
spec:
updateStrategy:
type: RollingUpdate
selector:
matchLabels:
app: csi-secrets-store-provider-azure
template:
metadata:
labels:
app: csi-secrets-store-provider-azure
spec:
tolerations:
containers:
- name: provider-azure-installer
image: {{ContainerImage "csi-secrets-store-provider-azure"}}
imagePullPolicy: Always
resources:
requests:
cpu: 50m
memory: 100Mi
limits:
cpu: 50m
memory: 100Mi
env:
# set TARGET_DIR env var and mount the same directory to to the container
- name: TARGET_DIR
value: "/etc/kubernetes/secrets-store-csi-providers"
volumeMounts:
- mountPath: "/etc/kubernetes/secrets-store-csi-providers"
name: providervol
volumes:
- name: providervol
hostPath:
path: "/etc/kubernetes/secrets-store-csi-providers"
nodeSelector:
beta.kubernetes.io/os: linux
30 changes: 28 additions & 2 deletions pkg/api/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,10 @@ func (cs *ContainerService) setAddonsConfig(isUpgrade bool) {
}

defaultKeyVaultFlexVolumeAddonsConfig := KubernetesAddon{
Name: common.KeyVaultFlexVolumeAddonName,
Enabled: to.BoolPtr(DefaultKeyVaultFlexVolumeAddonEnabled && !cs.Properties.HasCoreOS() && !cs.Properties.IsAzureStackCloud()),
Name: common.KeyVaultFlexVolumeAddonName,
// key-vault flexvolume solution will be deprecated in favor of secrets-store-csi-driver for 1.15+
Enabled: to.BoolPtr(DefaultKeyVaultFlexVolumeAddonEnabled && !cs.Properties.HasCoreOS() && !cs.Properties.IsAzureStackCloud() &&
!common.IsKubernetesVersionGe(o.OrchestratorVersion, "1.16.0")),
Containers: []KubernetesContainerSpec{
{
Name: common.KeyVaultFlexVolumeAddonName,
Expand Down Expand Up @@ -770,6 +772,29 @@ func (cs *ContainerService) setAddonsConfig(isUpgrade bool) {
},
}

defaultSecretsStoreCSIDriverAddonsConfig := KubernetesAddon{
Name: common.SecretStoreCSIDriverAddonName,
Enabled: to.BoolPtr(DefaultSecretStoreCSIDriverAddonEnabled && common.IsKubernetesVersionGe(o.OrchestratorVersion, "1.15.0")),
Containers: []KubernetesContainerSpec{
{
Name: "livenessprobe",
Image: "quay.io/k8scsi/livenessprobe:v1.1.0",
},
{
Name: "csi-node-driver-registrar",
Image: "quay.io/k8scsi/csi-node-driver-registrar:v1.2.0",
},
{
Name: "csi-secrets-store",
Image: "docker.io/deislabs/secrets-store-csi:v0.0.8",
},
{
Name: "csi-secrets-store-provider-azure",
Image: "mcr.microsoft.com/k8s/csi/secrets-store/provider-azure:0.0.3",
},
},
}

// Allow folks to simply enable kube-dns at cluster creation time without also requiring that coredns be explicitly disabled
if !isUpgrade && o.KubernetesConfig.IsAddonEnabled(common.KubeDNSAddonName) {
defaultCorednsAddonsConfig.Enabled = to.BoolPtr(false)
Expand Down Expand Up @@ -811,6 +836,7 @@ func (cs *ContainerService) setAddonsConfig(isUpgrade bool) {
defaultsAntreaDaemonSetAddonsConfig,
defaultFlannelAddonsConfig,
defaultScheduledMaintenanceAddonsConfig,
defaultSecretsStoreCSIDriverAddonsConfig,
}
// Add default addons specification, if no user-provided spec exists
if o.KubernetesConfig.Addons == nil {
Expand Down
27 changes: 27 additions & 0 deletions pkg/api/addons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3576,6 +3576,33 @@ func TestSetAddonsConfig(t *testing.T) {
},
}, "1.15.4"),
},
{
name: "csi-secrets-store addon enabled",
cs: &ContainerService{
Properties: &Properties{
OrchestratorProfile: &OrchestratorProfile{
OrchestratorVersion: "1.15.4",
KubernetesConfig: &KubernetesConfig{
KubernetesImageBaseType: common.KubernetesImageBaseTypeGCR,
DNSServiceIP: DefaultKubernetesDNSServiceIP,
KubeletConfig: map[string]string{
"--cluster-domain": "cluster.local",
},
ClusterSubnet: DefaultKubernetesSubnet,
ProxyMode: KubeProxyModeIPTables,
NetworkPlugin: NetworkPluginAzure,
},
},
},
},
isUpgrade: false,
expectedAddons: concatenateDefaultAddons([]KubernetesAddon{
{
Name: common.SecretStoreCSIDriverAddonName,
Enabled: to.BoolPtr(true),
},
}, "1.15.4"),
},
}

for _, test := range tests {
Expand Down
6 changes: 4 additions & 2 deletions pkg/api/common/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,13 @@ const (
CSIAttacherContainerName = "csi-attacher"
// CSIClusterDriverRegistrarContainerName is the name of the csi-cluster-driver-registrar container in the azuredisk-csi-driver and azurefile-csi-driver addons
CSIClusterDriverRegistrarContainerName = "csi-cluster-driver-registrar"
// CSILivenessProbeContainerName is the name of the livenessprobe container in the azuredisk-csi-driver and azurefile-csi-driver addons
// CSILivenessProbeContainerName is the name of the livenessprobe container in the azuredisk-csi-driver, azurefile-csi-driver and secrets-store-csi-driver addons
CSILivenessProbeContainerName = "livenessprobe"
// CSISnapshotterContainerName is the name of the csi-snapshotter container in the azuredisk-csi-driver addon
CSISnapshotterContainerName = "csi-snapshotter"
// CSIResizerContainerName is the name of the csi-resizer container in the azuredisk-csi-driver addon
CSIResizerContainerName = "csi-resizer"
// CSINodeDriverRegistrarContainerName is the name of the csi-node-driver-registrar container in the azuredisk-csi-driver and azurefile-csi-driver addons
// CSINodeDriverRegistrarContainerName is the name of the csi-node-driver-registrar container in the azuredisk-csi-driver, azurefile-csi-driver and secrets-store-csi-driver addons
CSINodeDriverRegistrarContainerName = "csi-node-driver-registrar"
// CSIAzureDiskContainerName is the name of the azuredisk-csi container in the azuredisk-csi-driver and azurefile-csi-driver addons
CSIAzureDiskContainerName = "azuredisk-csi"
Expand Down Expand Up @@ -268,6 +268,8 @@ const (
PodSecurityPolicyAddonName = "pod-security-policy"
// NodeProblemDetectorAddonName is the name of the node problem detector addon
NodeProblemDetectorAddonName = "node-problem-detector"
// SecretStoreCSIDriverAddonName is the name of the secrets-store-csi-driver addon
SecretStoreCSIDriverAddonName = "csi-secrets-store"
)

// Component name consts
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ const (
DefaultCoreDNSAddonEnabled = true
// DefaultKubeProxyAddonEnabled determines the aks-engine provided default for enabling kube-proxy addon
DefaultKubeProxyAddonEnabled = true
// DefaultSecretStoreCSIDriverAddonEnabled determins the aks-engine provided default for enabling secrets-store-csi-driver addon
DefaultSecretStoreCSIDriverAddonEnabled = true
// DefaultRBACEnabled determines the aks-engine provided default for enabling kubernetes RBAC
DefaultRBACEnabled = true
// DefaultUseInstanceMetadata determines the aks-engine provided default for enabling Azure cloudprovider instance metadata service
Expand Down
7 changes: 7 additions & 0 deletions pkg/api/vlabs/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,9 @@ func (a *Properties) validateAddons() error {
if a.HasCoreOS() {
return errors.New("flexvolume add-ons not currently supported on coreos distro. Please use Ubuntu")
}
if common.IsKubernetesVersionGe(a.OrchestratorProfile.OrchestratorVersion, "1.16.0") {
return errors.New(fmt.Sprintf("%s add-on is deprecated in favor of csi-secrets-store addon", addon.Name))
}
case "appgw-ingress":
if (a.ServicePrincipalProfile == nil || len(a.ServicePrincipalProfile.ObjectID) == 0) &&
!a.OrchestratorProfile.KubernetesConfig.UseManagedIdentity {
Expand Down Expand Up @@ -761,6 +764,10 @@ func (a *Properties) validateAddons() error {
kubeDNSEnabled = true
case common.CoreDNSAddonName:
corednsEnabled = true
case common.SecretStoreCSIDriverAddonName:
if !common.IsKubernetesVersionGe(a.OrchestratorProfile.OrchestratorVersion, "1.15.0") {
return errors.New(fmt.Sprintf("%s add-on can only be used in 1.15+", addon.Name))
}
}
} else {
// Validation for addons if they are disabled
Expand Down
Loading

0 comments on commit 4bb8eb4

Please sign in to comment.