Guest User

Untitled

a guest
Jan 23rd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. ---
  2. kind: Role
  3. apiVersion: rbac.authorization.k8s.io/v1
  4. metadata:
  5. namespace: default
  6. name: restart-pods
  7. rules:
  8. - apiGroups:
  9. - extensions
  10. - apps
  11. resources:
  12. - deployments
  13. - replicasets
  14. verbs:
  15. - 'patch'
  16. - 'get'
  17. ---
  18. kind: RoleBinding
  19. apiVersion: rbac.authorization.k8s.io/v1beta1
  20. metadata:
  21. name: restart-pods
  22. namespace: default
  23. subjects:
  24. - kind: ServiceAccount
  25. name: restart-pods-sa
  26. namespace: default
  27. roleRef:
  28. kind: Role
  29. name: restart-pods
  30. apiGroup: ""
  31. ---
  32. apiVersion: v1
  33. kind: ServiceAccount
  34. metadata:
  35. name: restart-pods-sa
  36. namespace: default
  37. ---
  38. apiVersion: batch/v1beta1
  39. kind: CronJob
  40. metadata:
  41. name: restart-pods
  42. namespace: default
  43. spec:
  44. # schedule: "0 */24 * * *"
  45. schedule: "*/1 * * * *"
  46. concurrencyPolicy: Replace
  47. jobTemplate:
  48. spec:
  49. template:
  50. spec:
  51. serviceAccountName: restart-pods-sa
  52. containers:
  53. - name: kubectl
  54. image: garland/kubectl:1.10.4
  55. command:
  56. - /bin/sh
  57. - -c
  58. - kubectl patch deployment api-gateway -p '{"spec":{"template":{"metadata":{"annotations":{"restarted-by":"'${POD_NAME}'", "restarted-at":"`date +'%s'`"}}}}}'
  59. env:
  60. - name: POD_NAME
  61. valueFrom:
  62. fieldRef:
  63. fieldPath: metadata.name
  64. restartPolicy: OnFailure
  65.  
  66.  
  67. # In case of `forbidden` errors when setting authorization rules:
  68. # kubectl create clusterrolebinding cluster-admin-binding \
  69. # --clusterrole cluster-admin \
  70. # --user $(gcloud config get-value account)
Add Comment
Please, Sign In to add comment