clusterCreateOpts.GlobalLabels[k3d.LabelNetworkExternal]="true"// if the network wasn't created, we say that it's managed externally (important for cluster deletion)
}
// just reserve some IPs for k3d (e.g. k3d-tools container), so we don't try to use them again
check_multi_node "$clustername"5|| failed_with_logfile"failed to verify number of nodes""$LOG_FILE"
check_multi_node "$clustername"5|| failed "failed to verify number of nodes"
# 2. check some config settings
## Environment Variables
info "Ensuring that environment variables are present in the node containers as set in the config (with comma)"
exec_in_node "k3d-$clustername-server-0""env"| grep -q "bar=baz,bob"|| failed_with_logfile"Expected env var 'bar=baz,bob' is not present in node k3d-$clustername-server-0""$LOG_FILE"
exec_in_node "k3d-$clustername-server-0""env"| grep -q "bar=baz,bob"|| failed "Expected env var 'bar=baz,bob' is not present in node k3d-$clustername-server-0"
## Container Labels
info "Ensuring that container labels have been set as stated in the config"
docker_assert_container_label "k3d-$clustername-server-0""foo=bar"|| failed_with_logfile"Expected label 'foo=bar' not present on container/node k3d-$clustername-server-0""$LOG_FILE"
docker_assert_container_label "k3d-$clustername-server-0""foo=bar"|| failed "Expected label 'foo=bar' not present on container/node k3d-$clustername-server-0"
## K3s Node Labels
info "Ensuring that k3s node labels have been set as stated in the config"
k3s_assert_node_label "k3d-$clustername-server-0""foo=bar"|| failed_with_logfile"Expected label 'foo=bar' not present on node k3d-$clustername-server-0""$LOG_FILE"
k3s_assert_node_label "k3d-$clustername-server-0""foo=bar"|| failed "Expected label 'foo=bar' not present on node k3d-$clustername-server-0"
## Registry Node
registryname="registry.localhost"
info "Ensuring, that we have a registry node present"
$EXE node list "$registryname"|| failed_with_logfile"Expected registry node $registryname to be present""$LOG_FILE"
$EXE node list "$registryname"|| failed "Expected registry node $registryname to be present"
## merged registries.yaml
info "Ensuring, that the registries.yaml file contains both registries"
exec_in_node "k3d-$clustername-server-0""cat /etc/rancher/k3s/registries.yaml"| grep -qi "my.company.registry"|| failed_with_logfile"Expected 'my.company.registry' to be in the /etc/rancher/k3s/registries.yaml""$LOG_FILE"
exec_in_node "k3d-$clustername-server-0""cat /etc/rancher/k3s/registries.yaml"| grep -qi "$registryname"|| failed_with_logfile"Expected '$registryname' to be in the /etc/rancher/k3s/registries.yaml""$LOG_FILE"
exec_in_node "k3d-$clustername-server-0""cat /etc/rancher/k3s/registries.yaml"| grep -qi "my.company.registry"|| failed "Expected 'my.company.registry' to be in the /etc/rancher/k3s/registries.yaml"
exec_in_node "k3d-$clustername-server-0""cat /etc/rancher/k3s/registries.yaml"| grep -qi "$registryname"|| failed "Expected '$registryname' to be in the /etc/rancher/k3s/registries.yaml"
# Cleanup
info "Deleting cluster $clustername (using config file)..."
$EXE cluster delete --config "$configfile"|| failed_with_logfile"could not delete the cluster $clustername""$LOG_FILE"
$EXE cluster delete --config "$configfile"|| failed "could not delete the cluster $clustername"
expectedIPGateway="172.45.0.1"# k3d defaults to subnet_start+1 for the Gateway IP
expectedIPLabelServer0="172.45.0.3"
subnet="172.80.0.0/16"
expectedIPGateway="172.80.0.1"# k3d defaults to subnet_start+1 for the Gateway IP
expectedIPLabelServer0="172.80.0.3"
expectedIPServer0="$expectedIPLabelServer0/16"# k3d excludes the subnet_start (x.x.x.0) and then uses IPs in sequential order, but .2 will be used by the tools container that gathers information at start