In builtin/nomad/platform.go
, I added code like below for using service tag:
if p.config.Service != nil {
services := &api.Service{
Name: p.config.Service.Name,
Tags: p.config.Service.Tags,
PortLabel: "waypoint",
}
job.TaskGroups[0].Tasks[0].Services = []*api.Service{services}
}
waypoint.hcl
app "app" {
...
deploy {
use "nomad" {
service_port = 8082
service {
name = "app"
tags = [
"traefik.enable=true",
"traefik.tag=traefik",
"traefik.http.routers.waypoint.entrypoints=http",
"traefik.http.routers.waypoint.rule=Host(`hoge.com`) && Path(`/init`)"
]
}
}
}
}
But there is an error:
* Task group app validation failed: 1 error occurred:
* Task app validation failed: 1 error occurred:
* 1 error occurred:
* port label "waypoint" referenced by services app does not exist
So I removed PortLabel
for checking job definition.
if p.config.Service != nil {
services := &api.Service{
Name: p.config.Service.Name,
Tags: p.config.Service.Tags,
// PortLabel: "waypoint",
}
job.TaskGroups[0].Tasks[0].Services = []*api.Service{services}
}
result is
{
"Stop": false,
"Region": "global",
"Namespace": "default",
"ID": "app",
"ParentID": "",
"Name": "app",
"Type": "service",
"Priority": 10,
"AllAtOnce": false,
"Datacenters": [
"dc1"
],
"Constraints": null,
"Affinities": null,
"Spreads": null,
"TaskGroups": [
{
"Name": "app",
"Count": 1,
"Update": {
"Stagger": 30000000000,
"MaxParallel": 1,
"HealthCheck": "checks",
"MinHealthyTime": 10000000000,
"HealthyDeadline": 300000000000,
"ProgressDeadline": 600000000000,
"AutoRevert": false,
"AutoPromote": false,
"Canary": 0
},
"Migrate": {
"MaxParallel": 1,
"HealthCheck": "checks",
"MinHealthyTime": 10000000000,
"HealthyDeadline": 300000000000
},
"Constraints": null,
"Scaling": null,
"RestartPolicy": {
"Attempts": 2,
"Interval": 1800000000000,
"Delay": 15000000000,
"Mode": "fail"
},
"Tasks": [
{
"Name": "app",
"Driver": "docker",
"User": "",
"Config": {
"ports": [
"waypoint"
],
"image": ":3"
},
"Env": {
"WAYPOINT_SERVER_ADDR": "192.168.20.31:27328",
"PORT": "8082",
"WAYPOINT_DEPLOYMENT_ID": "01ENN4EW4GGZX7HCG58BS63CVP",
"WAYPOINT_SERVER_TLS": "1",
"WAYPOINT_CEB_INVITE_TOKEN": "4RmBPBvZ1Dke3ppuJieyjR7Lr8wopqSinzMDV9CBhbK1SCcBVQwdZFsTfyJ2yhzU6Fk8x8F4Afj43gFbV75LsPNyJt3jKmxAfDPD8CRp5sSsfg7ueCTDV9LmfweZNPsDqs2JGQgoHJWtzwmLRhhJ",
"WAYPOINT_SERVER_TLS_SKIP_VERIFY": "1"
},
"Services": [
{
"Name": "app",
"TaskName": "",
"PortLabel": "",
"AddressMode": "auto",
"EnableTagOverride": false,
"Tags": [
"traefik.enable=true",
"traefik.tag=traefik",
"traefik.http.routers.waypoint.entrypoints=http",
"traefik.http.routers.waypoint.rule=Host(`hoge.com`) && Path(`/init`)"
],
"CanaryTags": null,
"Checks": null,
"Connect": null,
"Meta": null,
"CanaryMeta": null
}
],
"Vault": null,
"Templates": null,
"Constraints": null,
"Affinities": null,
"Resources": {
"CPU": 100,
"MemoryMB": 300,
"DiskMB": 0,
"IOPS": 0,
"Networks": null,
"Devices": null
},
"RestartPolicy": {
"Attempts": 2,
"Interval": 1800000000000,
"Delay": 15000000000,
"Mode": "fail"
},
"DispatchPayload": null,
"Lifecycle": null,
"Meta": null,
"KillTimeout": 5000000000,
"LogConfig": {
"MaxFiles": 10,
"MaxFileSizeMB": 10
},
"Artifacts": null,
"Leader": false,
"ShutdownDelay": 0,
"VolumeMounts": null,
"KillSignal": "",
"Kind": "",
"CSIPluginConfig": null
}
],
"EphemeralDisk": {
"Sticky": false,
"SizeMB": 300,
"Migrate": false
},
"Meta": null,
"ReschedulePolicy": {
"Attempts": 0,
"Interval": 0,
"Delay": 30000000000,
"DelayFunction": "exponential",
"MaxDelay": 3600000000000,
"Unlimited": true
},
"Affinities": null,
"Spreads": null,
"Networks": [
{
"Mode": "host",
"Device": "",
"CIDR": "",
"IP": "",
"MBits": 10,
"DNS": null,
"ReservedPorts": null,
"DynamicPorts": [
{
"Label": "waypoint",
"Value": 0,
"To": 8082,
"HostNetwork": "default"
}
]
}
],
"Services": null,
"Volumes": null,
"ShutdownDelay": null,
"StopAfterClientDisconnect": null
}
],
"Update": {
"Stagger": 30000000000,
"MaxParallel": 1,
"HealthCheck": "",
"MinHealthyTime": 0,
"HealthyDeadline": 0,
"ProgressDeadline": 0,
"AutoRevert": false,
"AutoPromote": false,
"Canary": 0
},
"Multiregion": null,
"Periodic": null,
"ParameterizedJob": null,
"Dispatched": false,
"Payload": null,
"Meta": {
"waypoint.hashicorp.com/nonce": "2020-10-27T13:38:29.924855419Z",
"waypoint.hashicorp.com/id": "01ENN4G4WT8ZE7JWR1ZZP6X25G"
},
"ConsulToken": "",
"VaultToken": "",
"VaultNamespace": "",
"NomadTokenID": "",
"Status": "running",
"StatusDescription": "",
"Stable": true,
"Version": 0,
"SubmitTime": 1603805868486658300,
"CreateIndex": 4720439,
"ModifyIndex": 4720448,
"JobModifyIndex": 4720439
}
I am struggling with the code on Waypoint and the differences in the Nomad job files.
And it’s also due to my lack of familiarity with Nomad.
If anyone can figure it out, please let me know.