Skip to content

Commit

Permalink
implements #1, #3. Adds JobType, Template TaskConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce Smith committed Oct 29, 2020
1 parent 4b3044a commit 7786612
Show file tree
Hide file tree
Showing 49 changed files with 876 additions and 753 deletions.
2 changes: 2 additions & 0 deletions client/allocrunner/taskrunner/task_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,7 @@ func (tr *TaskRunner) buildTaskConfig() *drivers.TaskConfig {
ID: fmt.Sprintf("%s/%s/%s", alloc.ID, task.Name, invocationid),
Name: task.Name,
JobName: alloc.Job.Name,
JobType: alloc.Job.Type,
TaskGroupName: alloc.TaskGroup,
Resources: &drivers.Resources{
NomadResources: taskResources,
Expand All @@ -985,6 +986,7 @@ func (tr *TaskRunner) buildTaskConfig() *drivers.TaskConfig {
AllocDir: tr.taskDir.AllocDir,
StdoutPath: tr.logmonHookConfig.stdoutFifo,
StderrPath: tr.logmonHookConfig.stderrFifo,
Templates: task.Templates,
AllocID: tr.allocID,
NetworkIsolation: tr.networkIsolationSpec,
DNS: dns,
Expand Down
128 changes: 64 additions & 64 deletions command/agent/bindata_assetfs.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions command/assets/connect.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ job "countdash" {
# attribute = "${node.datacenter}"
# }


# targets can be used to define desired percentages of allocations
# for each targeted attribute value.
#
Expand Down
2 changes: 0 additions & 2 deletions command/assets/example.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ job "example" {
# interval = "10s"
# timeout = "2s"
# }

}

# The "restart" stanza configures a group's behavior on task failure. If
Expand Down Expand Up @@ -356,7 +355,6 @@ job "example" {
memory = 256 # 256MB
}


# The "template" stanza instructs Nomad to manage a template, such as
# a configuration file or script. This template can optionally pull data
# from Consul or Vault to populate runtime configuration data.
Expand Down
43 changes: 35 additions & 8 deletions demo/csi/ceph-csi-plugin/ceph-csi-plugin.hcl
Original file line number Diff line number Diff line change
@@ -1,119 +1,146 @@
job "ceph-csi-plugin" {
datacenters = ["dc1"]
type = "system"

group "nodes" {
task "ceph-node" {
driver = "docker"

template {
data = <<EOF
data = <<EOF
[{
"clusterID": "<clusterid>",
"monitors": [
{{range $index, $service := service "mon.ceph"}}{{if gt $index 0}}, {{end}}"{{.Address}}"{{end}}
]
}]
EOF

destination = "local/config.json"
change_mode = "restart"
}

config {
image = "quay.io/cephcsi/cephcsi:v2.1.2-amd64"

volumes = [
"./local/config.json:/etc/ceph-csi-config/config.json"
"./local/config.json:/etc/ceph-csi-config/config.json",
]

mounts = [
{
type = "tmpfs"
target = "/tmp/csi/keys"
readonly = false

tmpfs_options {
size = 1000000 # size in bytes
}
}
},
]

args = [
"--type=rbd",

# Name of the driver
"--drivername=rbd.csi.ceph.com",

"--logtostderr",
"--nodeserver=true",
"--endpoint=unix://csi/csi.sock",
"--instanceid=${attr.unique.platform.aws.instance-id}",
"--nodeid=${attr.unique.consul.name}",

# TCP port for liveness metrics requests (/metrics)
"--metricsport=${NOMAD_PORT_prometheus}",
]

privileged = true

resources {
cpu = 200
memory = 500

network {
mbits = 1

// prometheus metrics port
port "prometheus" {}
}
}
}

service {
name = "prometheus"
port = "prometheus"
tags = ["ceph-csi"]
}

csi_plugin {
id = "ceph-csi"
type = "node"
mount_dir = "/csi"
}
}
task "ceph-controller" {

task "ceph-controller" {
template {
data = <<EOF
data = <<EOF
[{
"clusterID": "<clusterid>",
"monitors": [
{{range $index, $service := service "mon.ceph"}}{{if gt $index 0}}, {{end}}"{{.Address}}"{{end}}
]
}]
EOF

destination = "local/config.json"
change_mode = "restart"
}

driver = "docker"

config {
image = "quay.io/cephcsi/cephcsi:v2.1.2-amd64"

volumes = [
"./local/config.json:/etc/ceph-csi-config/config.json"
"./local/config.json:/etc/ceph-csi-config/config.json",
]

resources {
cpu = 200
memory = 500

network {
mbits = 1

// prometheus metrics port
port "prometheus" {}
}
}

args = [
"--type=rbd",
"--controllerserver=true",
"--drivername=rbd.csi.ceph.com",
"--logtostderr",
"--endpoint=unix://csi/csi.sock",
"--metricsport=$${NOMAD_PORT_prometheus}",
"--nodeid=$${attr.unique.platform.aws.hostname}"
"--nodeid=$${attr.unique.platform.aws.hostname}",
]
}

service {
name = "prometheus"
port = "prometheus"
tags = ["ceph-csi"]
}

csi_plugin {
id = "ceph-csi"
type = "controller"
mount_dir = "/csi"
}
}
}
}
}
23 changes: 17 additions & 6 deletions demo/csi/ceph-csi-plugin/example_volume.hcl
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
type = "csi"
id = "testvol"

id = "testvol"

name = "test_volume"

# this must be strictly formatted, see README
external_id = "ffff-0024-01616094-9d93-4178-bf45-c7eac19e8b15-000000000000ffff-00000000-1111-2222-bbbb-cacacacacaca"
access_mode = "single-node-writer"
external_id = "ffff-0024-01616094-9d93-4178-bf45-c7eac19e8b15-000000000000ffff-00000000-1111-2222-bbbb-cacacacacaca"

access_mode = "single-node-writer"

attachment_mode = "block-device"
plugin_id = "ceph-csi"

plugin_id = "ceph-csi"

mount_options {
fs_type = "ext4"
}

parameters {}

secrets {
userID = "<userid>"
userKey = "<userkey>"
}

context {
# note: although these are 'parameters' in the ceph-csi spec
# they are passed through to the provider as 'context'
clusterID = "<clusterid>"
pool = "my_pool"
}

pool = "my_pool"
}
36 changes: 24 additions & 12 deletions demo/csi/cinder-csi-plugin/cinder-csi-plugin.hcl
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
job "cinder-csi-plugin" {
datacenters = ["dc1"]
type = "system"

group "nodes" {
vault {
policies = ["openstack-secrets-read"]
change_mode = "restart"
}

task "cinder-node" {
driver = "docker"

template {
data = <<EOF
data = <<EOF
[Global]
username = {{ with secret "kv/data/openstack/credentials"}}{{ .Data.data.username }}{{ end }}
password = {{ with secret "kv/data/openstack/credentials"}}{{ .Data.data.password }}{{ end }}
Expand All @@ -18,26 +21,33 @@ auth-url = https://service01a-c2.example.com:5001/
tenant-id = 5sd6f4s5df6sd6fs5ds65fd4f65s
region = RegionOne
EOF

destination = "local/cloud.conf"
change_mode = "restart"
}

config {
image = "docker.io/k8scloudprovider/cinder-csi-plugin:latest"
devices = [{
host_path = "/dev"
container_path = "/dev"
}]

devices = [
{
host_path = "/dev"
container_path = "/dev"
},
]

volumes = [
"./local/cloud.conf:/etc/config/cloud.conf"
"./local/cloud.conf:/etc/config/cloud.conf",
]

args = [
"/bin/cinder-csi-plugin",
"--endpoint=unix:///csi/csi.sock",
"--cloud-config=/etc/config/cloud.conf",
"--nodeid=${node.unique.name}",
"--cluster=${NOMAD_DC}"
"--cluster=${NOMAD_DC}",
]

privileged = true
}

Expand All @@ -47,10 +57,10 @@ EOF
mount_dir = "/csi"
}
}
task "cinder-controller" {

task "cinder-controller" {
template {
data = <<EOF
data = <<EOF
[Global]
username = {{ with secret "kv/data/openstack/credentials"}}{{ .Data.data.username }}{{ end }}
password = {{ with secret "kv/data/openstack/credentials"}}{{ .Data.data.password }}{{ end }}
Expand All @@ -59,23 +69,26 @@ auth-url = https://service01a-c2.example.com:5001/
tenant-id = asdfasdfasdfa09asd8fa09sdf8009as8df0sa98
region = RegionOne
EOF

destination = "local/cloud.conf"
change_mode = "restart"
}

driver = "docker"

config {
image = "docker.io/k8scloudprovider/cinder-csi-plugin:latest"

volumes = [
"./local/cloud.conf:/etc/config/cloud.conf"
"./local/cloud.conf:/etc/config/cloud.conf",
]

args = [
"/bin/cinder-csi-plugin",
"--endpoint=unix:///csi/csi.sock",
"--cloud-config=/etc/config/cloud.conf",
"--nodeid=${node.unique.name}",
"--cluster=${NOMAD_DC}"
"--cluster=${NOMAD_DC}",
]
}

Expand All @@ -87,4 +100,3 @@ EOF
}
}
}

21 changes: 14 additions & 7 deletions demo/csi/cinder-csi-plugin/example_volume.hcl
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
type = "csi"
id = "testvol"
name = "test_volume"
external_id = "56as4da-as524d-asd9-asd8-asdasd52555"
access_mode = "single-node-writer"
type = "csi"

id = "testvol"

name = "test_volume"

external_id = "56as4da-as524d-asd9-asd8-asdasd52555"

access_mode = "single-node-writer"

attachment_mode = "block-device"
plugin_id = "cinder-csi"

plugin_id = "cinder-csi"

mount_options {
fs_type = "ext4"
}
}
2 changes: 1 addition & 1 deletion dev/docker-clients/client.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ job "client" {

network {
mbits = 10
port "http" {}
port "http"{}
}
}

Expand Down
2 changes: 1 addition & 1 deletion e2e/connect/input/native-demo.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ job "cn-demo" {
}
}
}
}
}
Loading

0 comments on commit 7786612

Please sign in to comment.