Created
April 21, 2021 05:48
-
-
Save nguyenthang98/a6ab9aa9b384fd2ecf0f980f90b0468d to your computer and use it in GitHub Desktop.
Keepalived with Nomad
This file contains hidden or 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
| client { | |
| enabled = true | |
| node_class = "" | |
| no_host_uuid = false | |
| servers = ["10.253.155.163","10.253.155.17","10.253.155.102"] | |
| max_kill_timeout = "30s" | |
| network_speed = 0 | |
| cpu_total_compute = 0 | |
| gc_interval = "1m" | |
| gc_disk_usage_threshold = 80 | |
| gc_inode_usage_threshold = 70 | |
| gc_parallel_destroys = 2 | |
| reserved { | |
| cpu = 0 | |
| memory = 0 | |
| disk = 0 | |
| } | |
| meta { | |
| keepalived_priority = 150 | |
| } | |
| } | |
| plugin "docker" { | |
| config { | |
| allow_caps = ["CHOWN","DAC_OVERRIDE","FSETID","FOWNER","MKNOD","NET_RAW","SETGID","SETUID","SETFCAP","SETPCAP"," NET_BIND_SERVICE","SYS_CHROOT","KILL","AUDIT_WRITE","NET_ADMIN"] | |
| } | |
| } |
This file contains hidden or 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
| job "keepalived" { | |
| datacenters = ["dc1"] | |
| type = "system" | |
| group "keepalived" { | |
| task "keepalived" { | |
| driver = "docker" | |
| config { | |
| image = "osixia/keepalived:2.0.20" | |
| network_mode = "host" | |
| volumes = [ | |
| "local/:/container/environment/01-custom" | |
| ] | |
| cap_add = ["NET_ADMIN"] | |
| } | |
| template { | |
| destination = "local/env.yaml" | |
| change_mode = "restart" | |
| splay = "1m" | |
| data = <<EOH | |
| KEEPALIVED_VIRTUAL_IPS: | |
| - 10.253.155.254/24 | |
| KEEPALIVED_UNICAST_PEERS: | |
| {{- with $node := node -}} | |
| {{ range nodes }} | |
| {{- if ne .Address $node.Node.Address }} | |
| - {{ .Address }} | |
| {{- end -}} | |
| {{- end -}} | |
| {{- end }} | |
| KEEPALIVED_PRIORITY: {{ env "meta.keepalived_priority" }} | |
| KEEPALIVED_INTERFACE: {{ sockaddr "GetPrivateInterfaces | include \"network\" \"10.253.155.0/24\" | attr \"name\"" }} | |
| EOH | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment