Skip to content

Commit

Permalink
yaml: fixup kustomize.sh
Browse files Browse the repository at this point in the history
This patch changes the kustomize.sh logic, due to an evolution
in the kustomize CLI [0] where envvars will not be loaded automatically
anymore.

Also this adapats simplifies the logic using a single overridden configmap

[0] kubernetes-sigs/kustomize#4730

Signed-off-by: Nathan Skrzypczak <[email protected]>
  • Loading branch information
sknat committed Jan 4, 2023
1 parent 82c88a1 commit 8e6e33f
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 171 deletions.
1 change: 0 additions & 1 deletion test/scripts/vppdev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ vppdev_cli_gdb ()
exit 1
fi
local pid=$(docker exec -it $container cat /var/run/vpp/vpp.pid)
docker exec -it $container ln -s /home/hostuser $HOME
docker exec -it $container gdb -p $pid -ex continue
}

Expand Down
6 changes: 3 additions & 3 deletions yaml/base/calico-vpp-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ spec:
imagePullPolicy: IfNotPresent
envFrom:
- configMapRef:
name: calico-vpp-config
name: calico-vpp-config
env:
# Use Kubernetes API as the backing datastore.
- name: DATASTORE_TYPE
Expand Down Expand Up @@ -297,7 +297,7 @@ spec:
privileged: true
envFrom:
- configMapRef:
name: calico-vpp-config
name: calico-vpp-config
env:
# Use Kubernetes API as the backing datastore.
- name: DATASTORE_TYPE
Expand Down Expand Up @@ -332,7 +332,7 @@ spec:
mountPropagation: Bidirectional
- mountPath: /host
name: host-root
volumes:
volumes:
- name: lib-firmware
hostPath:
path: /lib/firmware
Expand Down
23 changes: 23 additions & 0 deletions yaml/overlays/dev/calico-vpp-dev-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
kind: ConfigMap
apiVersion: v1
metadata:
name: calico-vpp-config
namespace: calico-vpp-dataplane
data:
CALICOVPP_LOG_LEVEL: ${CALICOVPP_LOG_LEVEL}
SERVICE_PREFIX: ${SERVICE_PREFIX}
CALICOVPP_IPSEC_IKEV2_PSK: ${CALICOVPP_IPSEC_IKEV2_PSK}
CALICOVPP_INTERFACE: ${CALICOVPP_INTERFACE}
CALICOVPP_NATIVE_DRIVER: ${CALICOVPP_NATIVE_DRIVER}
CALICOVPP_SWAP_DRIVER: ${CALICOVPP_SWAP_DRIVER}
CALICOVPP_INIT_SCRIPT_TEMPLATE: ${CALICOVPP_INIT_SCRIPT_TEMPLATE}
CALICOVPP_CONFIG_TEMPLATE: ${CALICOVPP_CONFIG_TEMPLATE}
CALICOVPP_CONFIG_EXEC_TEMPLATE: ${CALICOVPP_CONFIG_EXEC_TEMPLATE}
DEBUG: ${DEBUG}
CALICOVPP_INITIAL_CONFIG: ${CALICOVPP_INITIAL_CONFIG}
CALICOVPP_DEBUG: ${CALICOVPP_DEBUG}
CALICOVPP_INTERFACES: ${CALICOVPP_INTERFACES}
CALICOVPP_FEATURE_GATES: ${CALICOVPP_FEATURE_GATES}
CALICOVPP_IPSEC: ${CALICOVPP_IPSEC}
CALICOVPP_SRV6: ${CALICOVPP_SRV6}
CALICOVPP_LOG_FORMAT: pretty
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,28 @@ spec:
- name: agent
image: ${CALICO_AGENT_IMAGE}
imagePullPolicy: ${IMAGE_PULL_POLICY}
envFrom:
- configMapRef:
name: calico-agent-dev-config
env:
- name: DATASTORE_TYPE
value: "kubernetes"
- name: WAIT_FOR_DATASTORE
value: "true"
- name: NODENAME
value: ""
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: vpp
image: ${CALICO_VPP_IMAGE}
imagePullPolicy: ${IMAGE_PULL_POLICY}
envFrom:
- configMapRef:
name: vpp-dev-config
env:
- name: DATASTORE_TYPE
value: "kubernetes"
- name: WAIT_FOR_DATASTORE
value: "true"
- name: NODENAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: LD_LIBRARY_PATH
value: "/repo/vpp-manager/vpp_build/build-root/install-vpp-native/vpp/"
- name: DATASTORE_TYPE
value: kubernetes
- name: WAIT_FOR_DATASTORE
value: "true"
- name: NODENAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
# Updates to -env below
- name: LD_LIBRARY_PATH
value: "/repo/vpp-manager/vpp_build/build-root/install-vpp-native/vpp/"
resources:
requests:
cpu: 1
memory: 4Gi
limits:
memory: 80Gi
hugepages-2Mi: 4Gi
volumeMounts:
# Add your home to the container we can launch rebulid vpp
# without the whole container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,5 @@ spec:
containers:
- name: vpp
resources:
requests:
cpu: 1
memory: 4Gi
limits:
memory: 80Gi
hugepages-2Mi: 4Gi
hugepages-2Mi:
180 changes: 65 additions & 115 deletions yaml/overlays/dev/kustomize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ function get_initial_config ()
{
echo "
{
\"vppStartupSleepSeconds\": ${CALICOVPP_VPP_STARTUP_SLEEP:=0},
\"corePattern\": \"${CALICOVPP_CORE_PATTERN}\",
\"vppStartupSleepSeconds\": ${CALICOVPP_VPP_STARTUP_SLEEP:-0},
\"corePattern\": \"${CALICOVPP_CORE_PATTERN:-/repo/vppcore.%e.%p}\",
\"defaultGWs\": \"${CALICOVPP_DEFAULT_GW}\"
}
"
Expand All @@ -124,10 +124,10 @@ function get_feature_gates ()
{
echo "
{
\"memifEnabled\": ${CALICOVPP_ENABLE_MEMIF},
\"vclEnabled\": ${CALICOVPP_ENABLE_VCL},
\"multinetEnabled\": ${CALICOVPP_ENABLE_MULTINET},
\"ipsecEnabled\": ${CALICOVPP_IPSEC_ENABLED}
\"memifEnabled\": ${CALICOVPP_ENABLE_MEMIF:false},
\"vclEnabled\": ${CALICOVPP_ENABLE_VCL:false},
\"multinetEnabled\": ${CALICOVPP_ENABLE_MULTINET:false},
\"ipsecEnabled\": ${CALICOVPP_IPSEC_ENABLED:false}
}
"
}
Expand All @@ -136,10 +136,10 @@ function get_debug ()
{
echo "
{
\"policiesEnabled\": ${CALICOVPP_DEBUG_ENABLE_POLICIES},
\"servicesEnabled\": ${CALICOVPP_DEBUG_ENABLE_SERVICES},
\"maglevEnabled\": ${CALICOVPP_DEBUG_ENABLE_MAGLEV},
\"gsoEnabled\": ${CALICOVPP_DEBUG_ENABLE_GSO}
\"policiesEnabled\": ${CALICOVPP_DEBUG_ENABLE_POLICIES:-true},
\"servicesEnabled\": ${CALICOVPP_DEBUG_ENABLE_SERVICES:-true},
\"maglevEnabled\": ${CALICOVPP_DEBUG_ENABLE_MAGLEV:-true},
\"gsoEnabled\": ${CALICOVPP_DEBUG_ENABLE_GSO:-true}
}
"
}
Expand All @@ -149,24 +149,24 @@ function get_interfaces ()
echo "
{
\"defaultPodIfSpec\": {
\"rx\": ${CALICOVPP_RX_QUEUES:=1},
\"tx\": ${CALICOVPP_TX_QUEUES:=1},
\"rx\": ${CALICOVPP_RX_QUEUES:-1},
\"tx\": ${CALICOVPP_TX_QUEUES:-1},
\"isl3\": true,
\"rxMode\": \"${CALICOVPP_RX_MODE:=adaptive}\"
\"rxMode\": \"${CALICOVPP_RX_MODE:-adaptive}\"
},
\"vppHostTapSpec\": {
\"rx\": ${CALICOVPP_TAP_RX_QUEUES:=1},
\"tx\": ${CALICOVPP_TAP_TX_QUEUES:=1},
\"rxqsz\": 1024,
\"txqsz\": 1024,
\"rx\": ${CALICOVPP_TAP_RX_QUEUES:-1},
\"tx\": ${CALICOVPP_TAP_TX_QUEUES:-1},
\"rxqsz\": 1024,
\"txqsz\": 1024,
\"isl3\": false,
\"rxMode\": \"${CALICOVPP_TAP_RX_MODE:=adaptive}\"
\"rxMode\": \"${CALICOVPP_TAP_RX_MODE:-adaptive}\"
},
\"uplinkInterfaces\": [
{
\"interfaceName\": \"${CALICOVPP_INTERFACE:=eth0}\",
\"vppDriver\": \"${CALICOVPP_NATIVE_DRIVER:=af_packet}\",
\"rxMode\": \"${CALICOVPP_RX_MODE:=adaptive}\"
\"interfaceName\": \"${CALICOVPP_INTERFACE:-eth0}\",
\"vppDriver\": \"${CALICOVPP_NATIVE_DRIVER:-af_packet}\",
\"rxMode\": \"${CALICOVPP_RX_MODE:-adaptive}\"
}
]
}"
Expand Down Expand Up @@ -206,6 +206,13 @@ function is_v4_v46_v6 ()
fi
}

function get_empty_object ()
{
echo "
{}
"
}

calico_create_template ()
{
kustomize_parse_variables
Expand All @@ -226,120 +233,63 @@ calico_create_template ()
exit 1
fi

WRK=${WRK:=0}
MAINCORE=${MAINCORE:=12}
DPDK=${DPDK:=true}
WRK=${WRK:-0}
MAINCORE=${MAINCORE:-12}
DPDK=${DPDK:-true}

export CALICO_AGENT_IMAGE=${CALICO_AGENT_IMAGE:=docker.io/calicovpp/agent:latest}
export CALICO_VPP_IMAGE=${CALICO_VPP_IMAGE:=docker.io/calicovpp/vpp:latest}
export MULTINET_MONITOR_IMAGE=${MULTINET_MONITOR_IMAGE:=docker.io/calicovpp/multinet-monitor:latest}
export CALICO_VERSION_TAG=${CALICO_VERSION_TAG:=v3.20.0}
export CALICO_CNI_IMAGE=${CALICO_CNI_IMAGE:=docker.io/calico/cni:${CALICO_VERSION_TAG}}
export IMAGE_PULL_POLICY=${IMAGE_PULL_POLICY:=IfNotPresent}
export CALICO_AGENT_IMAGE=${CALICO_AGENT_IMAGE:-docker.io/calicovpp/agent:latest}
export CALICO_VPP_IMAGE=${CALICO_VPP_IMAGE:-docker.io/calicovpp/vpp:latest}
export MULTINET_MONITOR_IMAGE=${MULTINET_MONITOR_IMAGE:-docker.io/calicovpp/multinet-monitor:latest}
export CALICO_VERSION_TAG=${CALICO_VERSION_TAG:-v3.20.0}
export CALICO_CNI_IMAGE=${CALICO_CNI_IMAGE:-docker.io/calico/cni:${CALICO_VERSION_TAG}}
export IMAGE_PULL_POLICY=${IMAGE_PULL_POLICY:-IfNotPresent}

export USERHOME=${HOME}
export REPO_DIRECTORY=$(readlink -f ${SCRIPTDIR}/../../..)

## Installation ##

export CALICO_MTU=${CALICO_MTU:=0}
export CALICO_ENCAPSULATION_V4=${CALICO_ENCAPSULATION_V4:=IPIP}
export CALICO_ENCAPSULATION_V6=${CALICO_ENCAPSULATION_V6:=None}
export CALICO_NAT_OUTGOING=${CALICO_NAT_OUTGOING:=Enabled}
export CALICO_MTU=${CALICO_MTU:-0}
export CALICO_ENCAPSULATION_V4=${CALICO_ENCAPSULATION_V4:-IPIP}
export CALICO_ENCAPSULATION_V6=${CALICO_ENCAPSULATION_V6:-None}
export CALICO_NAT_OUTGOING=${CALICO_NAT_OUTGOING:-Enabled}
export CLUSTER_POD_CIDR4=${CLUSTER_POD_CIDR4}
export INSTALLATION_CIDRS=$(get_installation_cidrs)

# export CALICO_IPV4POOL_CIDR=$CLUSTER_POD_CIDR4
# export CALICO_IPV6POOL_CIDR=$CLUSTER_POD_CIDR6
# export FELIX_IPV6SUPPORT=$(is_v4_v46_v6 false true true)
# export IP=$(is_v4_v46_v6 autodetect autodetect none)
# export IP6=$(is_v4_v46_v6 none autodetect autodetect)
# export cni_network_config=$(get_cni_network_config)
# export FELIX_XDPENABLED=${FELIX_XDPENABLED:=false}


## calico-vpp-config variables ##
export SERVICE_PREFIX=$SERVICE_CIDR
export CALICOVPP_INTERFACE=${CALICOVPP_INTERFACE:=eth0}
export CALICOVPP_NATIVE_DRIVER=${CALICOVPP_NATIVE_DRIVER}
export CALICOVPP_CONFIG_TEMPLATE=${CALICOVPP_CONFIG_TEMPLATE:=$(get_vpp_conf)}

## vpp-dev-config variables (extra variables for VPP-manager) ##
export CALICOVPP_CORE_PATTERN=${CALICOVPP_CORE_PATTERN:=/home/hostuser/vppcore.%e.%p}
export CALICOVPP_RX_MODE=${CALICOVPP_RX_MODE:=adaptive}
export CALICOVPP_RX_QUEUES=${CALICOVPP_RX_QUEUES}
export CALICOVPP_VPP_STARTUP_SLEEP=${CALICOVPP_VPP_STARTUP_SLEEP:=0}
export CALICOVPP_CONFIG_EXEC_TEMPLATE=${CALICOVPP_CONFIG_EXEC_TEMPLATE}
export CALICOVPP_INIT_SCRIPT_TEMPLATE=${CALICOVPP_INIT_SCRIPT_TEMPLATE}
export CALICOVPP_DEFAULT_GW=${CALICOVPP_DEFAULT_GW}
export CALICOVPP_DEBUG_ENABLE_GSO=${CALICOVPP_DEBUG_ENABLE_GSO:=true}
export CALICOVPP_TAP_MTU=${CALICOVPP_TAP_MTU:=0}
export DEBUG=${DEBUG}

## calico-agent-config variables (extra variables for Calico-vpp-agent) ##
export CALICOVPP_TAP_RX_QUEUES=${CALICOVPP_TAP_RX_QUEUES:=1}
export CALICOVPP_TAP_TX_QUEUES=${CALICOVPP_TAP_TX_QUEUES:=1}
export CALICOVPP_IPSEC_ENABLED=${CALICOVPP_IPSEC_ENABLED:=false}
export CALICOVPP_DEBUG_ENABLE_POLICIES=${CALICOVPP_DEBUG_ENABLE_POLICIES:=true}
export CALICOVPP_DEBUG_ENABLE_SERVICES=${CALICOVPP_DEBUG_ENABLE_SERVICES:=true}
export CALICOVPP_DEBUG_ENABLE_MAGLEV=${CALICOVPP_DEBUG_ENABLE_MAGLEV:=true}
export CALICOVPP_ENABLE_MULTINET=${CALICOVPP_ENABLE_MULTINET:=false}
export CALICOVPP_ENABLE_MEMIF=${CALICOVPP_ENABLE_MEMIF:=true}
export CALICOVPP_ENABLE_VCL=${CALICOVPP_ENABLE_VCL:=true}
export CALICOVPP_IPSEC_IKEV2_PSK=${CALICOVPP_IPSEC_IKEV2_PSK:=keykeykey}

export CALICOVPP_INITIAL_CONFIG=${CALICOVPP_INITIAL_CONFIG:=$(get_initial_config)}
export CALICOVPP_INTERFACES=${CALICOVPP_INTERFACES:=$(get_interfaces)}
export CALICOVPP_DEBUG=${CALICOVPP_DEBUG:=$(get_debug)}

if [ x$CALICOVPP_ENABLE_MULTINET = xtrue ]; then export USE_MULTINET_MONITOR_DEV_PATCH=true ; fi
export CALICOVPP_INTERFACE='"'${CALICOVPP_INTERFACE:-}'"' # DEPRECATED
export CALICOVPP_NATIVE_DRIVER='"'${CALICOVPP_NATIVE_DRIVER}'"' # DEPRECATED
export CALICOVPP_SWAP_DRIVER='"'${CALICOVPP_SWAP_DRIVER}'"' # DEPRECATED
export CALICOVPP_CONFIG_EXEC_TEMPLATE='"'${CALICOVPP_CONFIG_EXEC_TEMPLATE}'"'
export CALICOVPP_INIT_SCRIPT_TEMPLATE='"'${CALICOVPP_INIT_SCRIPT_TEMPLATE}'"'
export CALICOVPP_IPSEC_IKEV2_PSK='"'${CALICOVPP_IPSEC_IKEV2_PSK:-keykeykey}'"'
export CALICOVPP_LOG_LEVEL='"'${CALICOVPP_LOG_LEVEL}'"'
export DEBUG='"'${DEBUG}'"'

export CALICOVPP_CONFIG_TEMPLATE="|- ${CALICOVPP_CONFIG_TEMPLATE:-$(get_vpp_conf)}"
export CALICOVPP_INITIAL_CONFIG="|- ${CALICOVPP_INITIAL_CONFIG:-$(get_initial_config)}"
export CALICOVPP_INTERFACES="|- ${CALICOVPP_INTERFACES:-$(get_interfaces)}"
export CALICOVPP_DEBUG="|- ${CALICOVPP_DEBUG:-$(get_debug)}"
export CALICOVPP_FEATURE_GATES="|- ${CALICOVPP_FEATURE_GATES:-$(get_empty_object)}"
export CALICOVPP_IPSEC="|- ${CALICOVPP_IPSEC:-$(get_empty_object)}"
export CALICOVPP_SRV6="|- ${CALICOVPP_SRV6:-$(get_empty_object)}"

cd $SCRIPTDIR

cat > kustomization.yaml <<EOF
bases:
- ../../base
- installation-dev.yaml
${USE_MULTINET_MONITOR_DEV_PATCH:+components:}
${USE_MULTINET_MONITOR_DEV_PATCH:+ - ../../components/multinet}
configMapGenerator:
# extra dev config for the VPP-agent
- name: calico-agent-dev-config
namespace: calico-vpp-dataplane
env: props/calico-agent-dev-config.properties
# extra dev config for VPP
- name: vpp-dev-config
namespace: calico-vpp-dataplane
env: props/vpp-dev-config.properties
# Override base/calico-vpp-daemonset.yaml config variables
- name: calico-vpp-config
namespace: calico-vpp-dataplane
env: props/calico-vpp-config.properties
behavior: merge
generatorOptions:
disableNameSuffixHash: true
EOF

echo "
components:
${CALICOVPP_ENABLE_MULTINET:+ - ../../components/multinet}
patchesStrategicMerge:
- calico-vpp-daemonset-dev-patch-nohuge.yaml
${USE_MULTINET_MONITOR_DEV_PATCH:+ - multinet-monitor-dev-patch.yaml}" >> kustomization.yaml
- calico-vpp-dev-configmap.yaml
- calico-vpp-dev-patch.yaml
${CALICOVPP_ENABLE_MULTINET:+ - multinet-monitor-dev-patch.yaml}
${CALICOVPP_DISABLE_HUGEPAGES:+ - calico-vpp-nohuge.yaml}
EOF

if [ x$@ != xnohuge ]; then
echo "
patchesStrategicMerge:
- calico-vpp-daemonset-dev-patch.yaml
${USE_MULTINET_MONITOR_DEV_PATCH:+ - multinet-monitor-dev-patch.yaml}" >> kustomization.yaml
fi

kubectl kustomize . | \
envsubst | \
sed "s/^ name: vpp-dev-config/ name: vpp-dev-config\n namespace: calico-vpp-dataplane/g" | \
sed "s/^ name: calico-agent-dev-config/ name: calico-agent-dev-config\n namespace: calico-vpp-dataplane/g" | \
sed "s/^ name: calico-vpp-config/ name: calico-vpp-config\n namespace: calico-vpp-dataplane/g" | \
kubectl kustomize . | envsubst | \
tee /tmp/calico-vpp.yaml > /dev/null

rm kustomization.yaml
Expand Down
10 changes: 0 additions & 10 deletions yaml/overlays/dev/props/calico-agent-dev-config.properties

This file was deleted.

3 changes: 0 additions & 3 deletions yaml/overlays/dev/props/calico-vpp-config.properties

This file was deleted.

7 changes: 0 additions & 7 deletions yaml/overlays/dev/props/vpp-dev-config.properties

This file was deleted.

Loading

0 comments on commit 8e6e33f

Please sign in to comment.