Skip to content

Commit

Permalink
Deploy with Kustomize (#58)
Browse files Browse the repository at this point in the history
Iteration 1 of Kustomize work.
  • Loading branch information
arnaud-tincelin authored Jun 10, 2021
1 parent 6355065 commit 147b24b
Show file tree
Hide file tree
Showing 11 changed files with 242 additions and 1 deletion.
4 changes: 3 additions & 1 deletion deployment/aks-periscope.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Note: this file is deprecated and will be removed in a future release
# Use Kustomize to deploy the project
apiVersion: v1
kind: Namespace
metadata:
Expand Down Expand Up @@ -169,4 +171,4 @@ spec:
singular: diagnostic
kind: Diagnostic
shortNames:
- apd
- apd
23 changes: 23 additions & 0 deletions deployment/cluster-role-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: aks-periscope-role-binding
subjects:
- kind: ServiceAccount
name: aks-periscope-service-account
roleRef:
kind: ClusterRole
name: aks-periscope-role
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: aks-periscope-role-binding-view
subjects:
- kind: ServiceAccount
name: aks-periscope-service-account
roleRef:
kind: ClusterRole
name: view
apiGroup: rbac.authorization.k8s.io
11 changes: 11 additions & 0 deletions deployment/cluster-role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: aks-periscope-role
rules:
- apiGroups: ["","metrics.k8s.io"]
resources: ["pods", "nodes"]
verbs: ["get", "watch", "list"]
- apiGroups: ["aks-periscope.azure.github.com"]
resources: ["diagnostics"]
verbs: ["get", "watch", "list", "create", "patch"]
20 changes: 20 additions & 0 deletions deployment/config-map.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: containerlogs-config
data:
DIAGNOSTIC_CONTAINERLOGS_LIST: kube-system
---
apiVersion: v1
kind: ConfigMap
metadata:
name: kubeobjects-config
data:
DIAGNOSTIC_KUBEOBJECTS_LIST: kube-system/pod kube-system/service kube-system/deployment
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nodelogs-config
data:
DIAGNOSTIC_NODELOGS_LIST: /var/log/azure/cluster-provision.log /var/log/cloud-init.log
28 changes: 28 additions & 0 deletions deployment/crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: diagnostics.aks-periscope.azure.github.com
spec:
group: aks-periscope.azure.github.com
versions:
- name: v1
served: true
storage: true
validation:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
dns:
type: string
networkoutbound:
type: string
scope: Namespaced
names:
plural: diagnostics
singular: diagnostic
kind: Diagnostic
shortNames:
- apd
48 changes: 48 additions & 0 deletions deployment/daemon-set.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: aks-periscope
labels:
app: aks-periscope
spec:
selector:
matchLabels:
app: aks-periscope
template:
metadata:
labels:
app: aks-periscope
spec:
serviceAccountName: aks-periscope-service-account
hostPID: true
nodeSelector:
beta.kubernetes.io/os: linux
containers:
- name: aks-periscope
image: aksrepos.azurecr.io/staging/aks-periscope
securityContext:
privileged: true
imagePullPolicy: Always
env: []
envFrom:
- configMapRef:
name: containerlogs-config
- configMapRef:
name: kubeobjects-config
- configMapRef:
name: nodelogs-config
volumeMounts:
- mountPath: /aks-periscope
name: aks-periscope-storage
resources:
requests:
memory: "500Mi"
cpu: "250m"
limits:
memory: "2000Mi"
cpu: "1000m"
volumes:
- name: aks-periscope-storage
hostPath:
path: /var/log/aks-periscope
type: DirectoryOrCreate
34 changes: 34 additions & 0 deletions deployment/examples/kustomization_storage_account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- https://github.com/Azure/aks-periscope/blob/master/deployment/kustomization.yaml

secretGenerator:
- name: azureblob-secret
literals:
- AZURE_BLOB_SAS_KEY=<base 64 encoded value>

patches:
- target:
group: apps
kind: DaemonSet
name: aks-periscope
version: v1
patch: |-
- op: add
path: '/spec/template/spec/containers/0/env/-'
value:
name: AZURE_BLOB_ACCOUNT_NAME
value: <name>
- target:
group: apps
kind: DaemonSet
name: aks-periscope
version: v1
patch: |-
- op: add
path: '/spec/template/spec/containers/0/envFrom/-'
value:
secretRef:
name: azureblob-secret
17 changes: 17 additions & 0 deletions deployment/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: aks-periscope

resources:
- namespace.yaml
- cluster-role.yaml
- cluster-role-binding.yaml
- config-map.yaml
- crd.yaml
- daemon-set.yaml
- service-account.yaml

images:
- name: aksrepos.azurecr.io/staging/aks-periscope
newTag: v0.3
4 changes: 4 additions & 0 deletions deployment/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: aks-periscope
4 changes: 4 additions & 0 deletions deployment/service-account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: aks-periscope-service-account
50 changes: 50 additions & 0 deletions docs/kustomize.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Deploy with Kustomize

To store the logs an Azure Blob Service account is required.

Patch the DeamonSet to add the `AZURE_BLOB_ACCOUNT_NAME` env var:

```yaml
patches:
- target:
group: apps
kind: DaemonSet
name: aks-periscope
version: v1
patch: |-
- op: add
path: '/spec/template/spec/containers/0/env/-'
value:
name: AZURE_BLOB_ACCOUNT_NAME
value: your_account_name
```
## Connect to the Storage Account using a SAS key
Create the following secret to connect to the Storage Account using a SAS Key:
```yaml
secretGenerator:
- name: azureblob-secret
literals:
- AZURE_BLOB_SAS_KEY=your_sas_key_base_64_encoded

patches:
- target:
group: apps
kind: DaemonSet
name: aks-periscope
version: v1
patch: |-
- op: add
path: '/spec/template/spec/containers/0/envFrom/-'
value: |
secretRef:
name: azureblob-secret
```
## Apply
```sh
kubectl apply -f <(kustomize build)
```

0 comments on commit 147b24b

Please sign in to comment.