tools:test-dhcpd-container-switch-type-ni
Table of Contents
Topology
Project
resource "zedcloud_project" "demo_zededa_project_2" {
name = "TF-DEPLOY-PROJ-1"
title = "TF-DEPLOY-PROJ-1"
type = "TAG_TYPE_DEPLOYMENT"
tag_level_settings {
interface_ordering = "INTERFACE_ORDERING_ENABLED"
flow_log_transmission = "NETWORK_INSTANCE_FLOW_LOG_TRANSMISSION_ENABLED"
}
configuration_lock_policy {
type = "POLICY_TYPE_CONFIGURATION_LOCK"
configuration_lock_policy {
config_lock = "CONFIGURATION_LOCK_DISABLED"
}
}
attestation_policy {
type = "POLICY_TYPE_ATTESTATION"
attestation_policy {
type = "ATTEST_POLICY_TYPE_ACCEPT"
}
}
edgeview_policy {
type = "POLICY_TYPE_EDGEVIEW"
edgeview_policy {
access_allow_change = true
edgeview_allow = true
edgeviewcfg {
app_policy { allow_app = true }
dev_policy { allow_dev = true }
jwt_info {
disp_url = "zedcloud.gmwtus.zededa.net/api/v1/edge-view"
allow_sec = 18000
num_inst = 1
encrypt = false
}
ext_policy { allow_ext = true }
}
max_expire_sec = 2592000
max_inst = 3
}
}
}
Datastore
###########Create Docker Hub Registry
resource "zedcloud_datastore" "demo_docker_hub" {
ds_fqdn = "docker://docker.io"
ds_type = "DATASTORE_TYPE_CONTAINERREGISTRY"
name = "TF-ZED-DEMO-DOCKER-HUB"
title = "TF-ZED-DEMO-DOCKER-HUB"
project_access_list = []
}
Container Image
resource "zedcloud_image" "demo_dhcpd_1" {
datastore_id = zedcloud_datastore.demo_docker_hub.id
image_type = "IMAGE_TYPE_APPLICATION"
image_arch = "AMD64"
image_format = "CONTAINER"
image_size_bytes = 0
name = "TF-DHCPD"
title = "TF-DHCPD"
project_access_list = []
image_rel_url = "zedmanny/dhcpd-container:latest"
}
Persistent Volume
resource "zedcloud_volume_instance" "tf_demo_dhcpd_cont_persist" {
device_id = zedcloud_edgenode.demo_en_onlogic_cl250.id ### Edge Node ID
accessmode = "VOLUME_INSTANCE_ACCESS_MODE_READWRITE"
cleartext = false
label = "cl250-dhcpd-cont-persist"
name = "cl250-dhcpd-cont-persist"
size_bytes = 1073741824
title = "cl250-dhcpd-cont-persist"
type = "VOLUME_INSTANCE_TYPE_BLOCKSTORAGE"
}
Network Instance (switch type)
resource "zedcloud_network_instance" "tf_cl250_lan_switch_1" {
name = "TF-CL250-NI-1"
title = "TF-CL250-NI-1"
kind = "NETWORK_INSTANCE_KIND_SWITCH"
type = "NETWORK_INSTANCE_DHCP_TYPE_UNSPECIFIED"
port = "eth0"
device_id = zedcloud_edgenode.demo_en_onlogic_cl250.id
depends_on = []
}
App Template
resource "zedcloud_application" "tf_dhcpd_app_1" {
name = "TF-STND-DHCPD-APP-1"
title = "TF-STND-DHCPD-APP-1"
networks = 1
manifest {
ac_kind = "VMManifest"
ac_version = "1.2.0"
name = "TF-DHCPD-APP-1"
owner {
user = "Manny"
company = "Zededa"
website = "www.zededa.com"
email = "manny@zededa.com"
}
desc {
app_category = "APP_CATEGORY_CLOUD_APPLICATION"
category = "APP_CATEGORY_UNSPECIFIED"
logo = {
url = "https://upload.wikimedia.org/wikipedia/commons/thumb/6/6f/DHCP_Client-Server_model_-_en.png/250px-DHCP_Client-Server_model_-_en.png"
}
}
images {
imagename = zedcloud_image.demo_dhcpd_1.name
cleartext = false
ignorepurge = false
imageformat = "CONTAINER"
}
images { ### second drive: persistent block-storage volume mounted at /data (config.json + leases)
volumelabel = zedcloud_volume_instance.tf_demo_dhcpd_cont_persist.label
imageformat = "QCOW2"
mountpath = "/data"
cleartext = false
drvtype = "HDD"
ignorepurge = true
preserve = true
maxsize = 1073741824
target = "Disk"
}
interfaces {
name = "eth0"
type = "ip"
directattach = false
privateip = false
acls {
matches { ### Outbound rule
type = "ip"
value = "0.0.0.0/0"
}
}
}
vmmode = "HV_PV"
enablevnc = true
resources {
name = "resourceType"
value = "custom"
}
resources {
name = "cpus"
value = 2
}
resources {
name = "memory"
value = 2097152
}
configuration {
custom_config {
add = true
name = "cloud-config"
override = true
template = ""
}
}
app_type = "APP_TYPE_CONTAINER"
deployment_type = "DEPLOYMENT_TYPE_STAND_ALONE"
cpu_pinning_enabled = false
}
user_defined_version = "2" # bump to force a new app version
origin_type = "ORIGIN_LOCAL"
project_access_list = []
}
Deploy App
resource "zedcloud_application_instance" "demo_deploy_dhcpd_container" {
name = "tf-dhcpd-container-deploy"
title = "tf-dhcpd-container-deploy"
project_id = zedcloud_project.demo_zededa_project_1.id
app_id = zedcloud_application.tf_dhcpd_app_1.id
activate = true
device_id = zedcloud_edgenode.demo_en_onlogic_cl250.id
purge {
counter = 6 # bump to re-render cloud-init / redeploy (purges non-preserve drives)
}
custom_config {
add = true
allow_storage_resize = true
field_delimiter = "@@@"
name = "cloud-config"
override = true
template = base64encode(file("./c-init/dhcpd-2.txt")) # static 192.168.254.100/24 on eth0, then ISC dhcpd + web UI via supervisord
}
drives {
imagename = zedcloud_image.demo_dhcpd_1.name
cleartext = false
ignorepurge = true
maxsize = 10971520
preserve = false
target = "Disk"
drvtype = "HDD"
readonly = false
}
drives { ### second drive: persistent block-storage volume (use label, per convention)
imagename = ""
volumelabel = zedcloud_volume_instance.tf_demo_dhcpd_cont_persist.label
mountpath = "/data"
cleartext = false
ignorepurge = true
maxsize = 1073741824
preserve = true
target = "Disk"
drvtype = "HDD"
readonly = false
}
interfaces {
intfname = "eth0"
intforder = 1
directattach = false
access_vlan_id = 254 # access port on VLAN 254 of the VLAN-aware switch NI; EVE untags before eth0
default_net_instance = false
ipaddr = ""
macaddr = var.vm2_macaddr
netinstname = zedcloud_network_instance.tf_cl250_lan_switch_1.name
privateip = false
}
}
cloud-init
**This is the DHCP configuration the dhcpd container will deploy **
#cloud-config runcmd: - EVE_CONTAINER_NO_POWEROFF=1 - HOSTNAME="dhcpd-2" - DHCP_SUBNET="192.168.254.0" - DHCP_NETMASK="255.255.255.0" - DHCP_RANGE_START="192.168.254.150" - DHCP_RANGE_END="192.168.254.200" - DHCP_GATEWAY="192.168.254.1" - DHCP_DNS="1.1.1.1" - DHCP_FORCE_SEED="true"
Test Results
tools/test-dhcpd-container-switch-type-ni.txt · Last modified: by mc
