-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mikhail Scherba <[email protected]>
- Loading branch information
Showing
13 changed files
with
384 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: addon-operator | ||
data: | ||
global: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM flant/addon-operator:latest | ||
ADD modules /modules | ||
ADD global-hooks /global-hooks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
## onStartup global hooks example | ||
|
||
Example of a global hook written as bash script. | ||
|
||
### run | ||
|
||
Build addon-operator image with custom scripts: | ||
|
||
``` | ||
docker build -t "registry.mycompany.com/addon-operator:startup-global" . | ||
docker push registry.mycompany.com/addon-operator:startup-global | ||
``` | ||
|
||
Edit image in addon-operator-pod.yaml and apply manifests: | ||
|
||
``` | ||
kubectl create ns example-startup-global | ||
kubectl -n example-startup-global apply -f addon-operator-rbac.yaml | ||
kubectl -n example-startup-global apply -f addon-operator-pod.yaml | ||
``` | ||
|
||
See in logs that hook.sh was run at startup: | ||
|
||
``` | ||
kubectl -n example-startup-global logs pod/addon-operator -f | ||
... | ||
INFO : Initializing global hooks ... | ||
INFO : INIT: global hook 'hook.sh' ... | ||
... | ||
INFO : TASK_RUN GlobalHookRun@ON_STARTUP hook.sh | ||
INFO : Running global hook 'hook.sh' binding 'ON_STARTUP' ... | ||
OnStartup global hook | ||
... | ||
``` | ||
|
||
### cleanup | ||
|
||
``` | ||
kubectl delete clusterrolebinding/addon-operator | ||
kubectl delete clusterrole/addon-operator | ||
kubectl delete ns/example-startup-global | ||
docker rmi registry.mycompany.com/addon-operator:startup-global | ||
``` |
7 changes: 7 additions & 0 deletions
7
examples/002-startup-global-high-availability/addon-operator-cm.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: addon-operator | ||
data: | ||
global: "" |
71 changes: 71 additions & 0 deletions
71
examples/002-startup-global-high-availability/addon-operator-deployment.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
annotations: | ||
name: addon-operator | ||
spec: | ||
replicas: 2 | ||
selector: | ||
matchLabels: | ||
app: addon-operator | ||
strategy: | ||
rollingUpdate: | ||
maxSurge: 25% | ||
maxUnavailable: 1 | ||
type: RollingUpdate | ||
template: | ||
metadata: | ||
labels: | ||
app: addon-operator | ||
spec: | ||
affinity: | ||
podAntiAffinity: | ||
preferredDuringSchedulingIgnoredDuringExecution: | ||
- podAffinityTerm: | ||
labelSelector: | ||
matchExpressions: | ||
- key: app | ||
operator: In | ||
values: | ||
- addon-operator | ||
topologyKey: kubernetes.io/hostname | ||
weight: 100 | ||
containers: | ||
- env: | ||
- name: ADDON_OPERATOR_POD | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: metadata.name | ||
- name: ADDON_OPERATOR_HA | ||
value: "true" | ||
- name: ADDON_OPERATOR_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: metadata.namespace | ||
- name: ADDON_OPERATOR_LISTEN_ADDRESS | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: status.podIP | ||
image: registry.mycompany.com/addon-operator:ha | ||
imagePullPolicy: IfNotPresent | ||
name: addon-operator | ||
readinessProbe: | ||
httpGet: | ||
path: /readyz | ||
port: 9650 | ||
scheme: HTTP | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
timeoutSeconds: 1 | ||
resources: {} | ||
terminationMessagePath: /dev/termination-log | ||
terminationMessagePolicy: File | ||
dnsPolicy: ClusterFirst | ||
restartPolicy: Always | ||
schedulerName: default-scheduler | ||
serviceAccount: addon-operator-acc | ||
serviceAccountName: addon-operator-acc | ||
terminationGracePeriodSeconds: 30 |
34 changes: 34 additions & 0 deletions
34
examples/002-startup-global-high-availability/addon-operator-rbac.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: addon-operator-acc | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: addon-operator | ||
rules: | ||
- apiGroups: | ||
- "*" | ||
resources: | ||
- "*" | ||
verbs: | ||
- "*" | ||
- nonResourceURLs: | ||
- "*" | ||
verbs: | ||
- "*" | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: addon-operator | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: addon-operator | ||
subjects: | ||
- kind: ServiceAccount | ||
name: addon-operator-acc | ||
namespace: default |
Oops, something went wrong.