diff --git a/bindata/network/multus/002-rbac.yaml b/bindata/network/multus/002-rbac.yaml index c0fefa1945..c60ff44c92 100644 --- a/bindata/network/multus/002-rbac.yaml +++ b/bindata/network/multus/002-rbac.yaml @@ -230,26 +230,32 @@ kind: ClusterRole metadata: name: whereabouts-cni rules: -- apiGroups: - - whereabouts.cni.cncf.io +- apiGroups: ["whereabouts.cni.cncf.io"] resources: - - ippools - - overlappingrangeipreservations - - nodesliceippools - verbs: - - get - - list - - watch - - create - - update - - patch - - delete + - "nodeslicepools" + - "nodeslicepools/status" + - "nodeslicepools/finalizers" + - "ippools" + - "overlappingrangeipreservations" + verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] - apiGroups: [""] resources: - pods - verbs: - - list - + - nodes + verbs: ["get", "list", "watch"] +- apiGroups: ["k8s.cni.cncf.io"] + resources: + - "network-attachment-definitions" + - "network-attachment-definitions/finalizers" + verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] +- apiGroups: ["", "events.k8s.io"] + resources: + - events + verbs: ["create", "patch", "update"] +- apiGroups: ["coordination.k8s.io"] + resources: + - leases + verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role diff --git a/bindata/network/multus/multus.yaml b/bindata/network/multus/multus.yaml index bd94e5e778..21c738bdc8 100644 --- a/bindata/network/multus/multus.yaml +++ b/bindata/network/multus/multus.yaml @@ -42,7 +42,7 @@ data: RHEL_VERSION=$(echo "${CPE_NAME}" | cut -f 5 -d :) rhelmajor=$(echo $RHEL_VERSION | sed -E 's/([0-9]+)\.{1}[0-9]+(\.[0-9]+)?/\1/') ;; - rhel) rhelmajor=$(echo "${VERSION_ID}" | cut -f 1 -d .) + rhel|centos) rhelmajor=$(echo "${VERSION_ID}" | cut -f 1 -d .) ;; fedora) if [ "${VARIANT_ID}" == "coreos" ]; then @@ -106,6 +106,24 @@ data: fi rm -Rf $UPGRADE_DIRECTORY --- +apiVersion: v1 +kind: ConfigMap +metadata: + name: whereabouts-config + namespace: openshift-multus +data: + whereabouts.conf: | + { + "datastore": "kubernetes", + "kubernetes": { + "kubeconfig": "/etc/kubernetes/cni/net.d/whereabouts.d/whereabouts.kubeconfig" + }, + "reconciler_cron_expression": "30 4 * * *", + "log_level": "debug", + "log_file": "/tmp/whereabouts.log", + "configuration_path": "/etc/kubernetes/cni/net.d/whereabouts.d" + } +--- kind: ConfigMap apiVersion: v1 metadata: @@ -141,7 +159,8 @@ data: "readinessindicatorfile": "/host/run/multus/cni/net.d/10-ovn-kubernetes.conf", {{- end}} "daemonSocketDir": "/run/multus/socket", - "socketDir": "/host{{ .MultusSocketParentDir }}/socket" + "socketDir": "/host{{ .MultusSocketParentDir }}/socket", + "auxiliaryCNIChainName": "vendor-cni-chain" } {{- if .IsNetworkTypeLiveMigration}} daemon-config-lm-ovn.json: | @@ -157,7 +176,6 @@ data: "bootstrapKubeconfig": "{{ .KubeletKubeconfigPath }}", "certDir": "/etc/cni/multus/certs", "certDuration": "24h" - }, {{ end }} "cniConfigDir": "/host/etc/cni/net.d", "multusConfigFile": "auto", @@ -550,21 +568,43 @@ spec: CNI_BIN_DIR=${CNI_BIN_DIR:-"/host/opt/cni/bin/"} WHEREABOUTS_KUBECONFIG_FILE_HOST=${WHEREABOUTS_KUBECONFIG_FILE_HOST:-"/etc/cni/net.d/whereabouts.d/whereabouts.kubeconfig"} - CNI_CONF_DIR=${CNI_CONF_DIR:-"/host/etc/cni/net.d"} + CNI_CONF_DIR=${CNI_CONF_DIR:-"/host{{ .SystemCNIConfDir }}"} + WHEREABOUTS_RECONCILER_CRON=${WHEREABOUTS_RECONCILER_CRON:-30 4 * * *} # Make a whereabouts.d directory (for our kubeconfig) mkdir -p $CNI_CONF_DIR/whereabouts.d WHEREABOUTS_KUBECONFIG=$CNI_CONF_DIR/whereabouts.d/whereabouts.kubeconfig - WHEREABOUTS_GLOBALCONFIG=$CNI_CONF_DIR/whereabouts.d/whereabouts.conf + WHEREABOUTS_CONF_FILE=$CNI_CONF_DIR/whereabouts.d/whereabouts.conf + WHEREABOUTS_KUBECONFIG_LITERAL=$(echo "$WHEREABOUTS_KUBECONFIG" | sed -e s'|/host||') + + # Write the nodename to the whereabouts.d directory for standardized hostname reference across cloud providers + echo $NODENAME > $CNI_CONF_DIR/whereabouts.d/nodename - # ------------------------------- Generate a "kube-config" SERVICE_ACCOUNT_PATH=/var/run/secrets/kubernetes.io/serviceaccount KUBE_CA_FILE=${KUBE_CA_FILE:-$SERVICE_ACCOUNT_PATH/ca.crt} - SERVICEACCOUNT_TOKEN=$(cat $SERVICE_ACCOUNT_PATH/token) + SERVICE_ACCOUNT_TOKEN=$(cat $SERVICE_ACCOUNT_PATH/token) + SERVICE_ACCOUNT_TOKEN_PATH=$SERVICE_ACCOUNT_PATH/token SKIP_TLS_VERIFY=${SKIP_TLS_VERIFY:-false} + function log() + { + echo "$(date -Iseconds) ${1}" + } + + function error() + { + log "ERR: {$1}" + } + + function warn() + { + log "WARN: {$1}" + } + + + function generateKubeConfig { # Check if we're running as a k8s pod. if [ -f "$SERVICE_ACCOUNT_PATH/token" ]; then # We're running as a k8d pod - expect some variables. @@ -581,6 +621,12 @@ spec: TLS_CFG="certificate-authority-data: $(cat $KUBE_CA_FILE | base64 | tr -d '\n')" fi + # Kubernetes service address must be wrapped if it is IPv6 address + KUBERNETES_SERVICE_HOST_WRAP=$KUBERNETES_SERVICE_HOST + if [ "$KUBERNETES_SERVICE_HOST_WRAP" != "${KUBERNETES_SERVICE_HOST_WRAP#*:[0-9a-fA-F]}" ]; then + KUBERNETES_SERVICE_HOST_WRAP=\[$KUBERNETES_SERVICE_HOST_WRAP\] + fi + # Write a kubeconfig file for the CNI plugin. Do this # to skip TLS verification for now. We should eventually support # writing more complete kubeconfig files. This is only used @@ -588,18 +634,18 @@ spec: touch $WHEREABOUTS_KUBECONFIG chmod ${KUBECONFIG_MODE:-600} $WHEREABOUTS_KUBECONFIG cat > $WHEREABOUTS_KUBECONFIG < $WHEREABOUTS_GLOBALCONFIG < $WHEREABOUTS_CONF_FILE < $WHEREABOUTS_KUBECONFIG <