Skip to content

Commit

Permalink
Move example addon resizer deployment out of README. Add RBAC to make…
Browse files Browse the repository at this point in the history
… it wokr
  • Loading branch information
bskiba committed Nov 29, 2019
1 parent d0cca15 commit fe53132
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 74 deletions.
75 changes: 1 addition & 74 deletions addon-resizer/README.md
Expand Up @@ -44,80 +44,7 @@ Usage of ./pod_nanny:

## Example deployment file

The following yaml is an example deployment where the nanny watches and resizes itself.

```yaml
# Config map for resource configuration.
# Specify 'cpu', 'extra-cpu', 'memory' and 'extra-memory'
# to overwrite resource requirements.
apiVersion: v1
kind: ConfigMap
metadata:
name: nanny-config
namespace: default
data:
NannyConfiguration: |-
apiVersion: nannyconfig/v1alpha1
kind: NannyConfiguration
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nanny-v1
namespace: default
labels:
k8s-app: nanny
version: v1
spec:
replicas: 1
selector:
matchLabels:
k8s-app: nanny
version: v1
template:
metadata:
labels:
k8s-app: nanny
version: v1
kubernetes.io/cluster-service: "true"
spec:
containers:
- image: gcr.io/google-containers/addon-resizer-amd64:2.1
imagePullPolicy: Always
name: pod-nanny
resources:
limits:
cpu: 300m
memory: 200Mi
requests:
cpu: 300m
memory: 200Mi
env:
- name: MY_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: MY_POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
volumeMounts:
- name: nanny-config-volume
mountPath: /etc/config
command:
- /pod_nanny
- --config-dir=/etc/config
- --cpu=300m
- --extra-cpu=20m
- --memory=200Mi
- --extra-memory=10Mi
- --threshold=5
- --deployment=nanny-v1
volumes:
- name: nanny-config-volume
configMap:
name: nanny-config
```
You can take a look at an [example deployment](./deploy/example.yaml) where the nanny watches and resizes itself.

## Addon resizer configuration

Expand Down
117 changes: 117 additions & 0 deletions addon-resizer/deploy/example.yaml
@@ -0,0 +1,117 @@
# Config map for resource configuration.
# Specify 'cpu', 'extra-cpu', 'memory' and 'extra-memory'
# to overwrite resource requirements.
apiVersion: v1
kind: ConfigMap
metadata:
name: nanny-config
namespace: default
data:
NannyConfiguration: |-
apiVersion: nannyconfig/v1alpha1
kind: NannyConfiguration
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: pod-nanny
namespace: default
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nanny-v1
namespace: default
labels:
k8s-app: nanny
version: v1
spec:
replicas: 1
selector:
matchLabels:
k8s-app: nanny
version: v1
template:
metadata:
labels:
k8s-app: nanny
version: v1
kubernetes.io/cluster-service: "true"
spec:
serviceAccountName: pod-nanny
containers:
- image: gcr.io/bskiba-gke-dev/addon-resizer:1.8.7
imagePullPolicy: Always
name: pod-nanny
resources:
limits:
cpu: 300m
memory: 200Mi
requests:
cpu: 300m
memory: 200Mi
env:
- name: MY_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: MY_POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
volumeMounts:
- name: nanny-config-volume
mountPath: /etc/config
command:
- /pod_nanny
- --config-dir=/etc/config
- --cpu=300m
- --extra-cpu=20m
- --memory=200Mi
- --extra-memory=10Mi
- --threshold=5
- --deployment=nanny-v1
volumes:
- name: nanny-config-volume
configMap:
name: nanny-config
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: default:pod-nanny
namespace: default
rules:
- apiGroups:
- ""
resources:
- pods
- nodes
verbs:
- get
- list
- watch
- apiGroups:
- "apps"
resources:
- deployments
verbs:
- get
- list
- update
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: pod-nanny-binding
namespace: default
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: default:pod-nanny
subjects:
- kind: ServiceAccount
name: pod-nanny
namespace: default
---

0 comments on commit fe53132

Please sign in to comment.