Skip to content

Commit be3aa7c

Browse files
Merge pull request #1024 from hjensas/nncp-dns
DNS only NNCP
2 parents 466cdcb + 2687beb commit be3aa7c

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

Makefile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2329,10 +2329,23 @@ else
23292329
endif
23302330

23312331
.PHONY: nncp_with_retries
2332-
nncp_with_retries: ## Deploy NNCP with retries
2332+
nncp_with_retries: nncp_dns ## Deploy NNCP with retries
23332333
$(eval $(call vars,$@))
23342334
bash scripts/retry_make_nncp.sh $(NNCP_RETRIES)
23352335

2336+
.PHONY: nncp_dns
2337+
nncp_dns: export DNS_SERVER=${NNCP_DNS_SERVER}
2338+
nncp_dns:
2339+
$(eval $(call vars,$@,nncp))
2340+
ifeq ($(NNCP_NODES),)
2341+
WORKERS='$(shell oc get nodes -l node-role.kubernetes.io/worker -o jsonpath="{.items[*].metadata.name}")' \
2342+
bash scripts/gen-nncp-dns.sh
2343+
else
2344+
WORKERS=${NNCP_NODES} bash scripts/gen-nncp-dns.sh
2345+
endif
2346+
oc apply -f ${DEPLOY_DIR}/
2347+
timeout ${NNCP_TIMEOUT} bash -c "while ! (oc wait nncp -l osp/interface=nncp-dns --for jsonpath='{.status.conditions[0].reason}'=SuccessfullyConfigured); do sleep 10; done"
2348+
oc delete nncp -l osp/interface=nncp-dns
23362349

23372350
.PHONY: nncp
23382351
nncp: export INTERFACE=${NNCP_INTERFACE}

scripts/gen-nncp-dns.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2022 Red Hat Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
set -ex
17+
18+
function check_var_set {
19+
if [[ ! -v $1 ]]; then
20+
echo "Please set $1"; exit 1
21+
fi
22+
}
23+
24+
STATE=$1
25+
26+
check_var_set DEPLOY_DIR
27+
28+
if [ ! -d ${DEPLOY_DIR} ]; then
29+
mkdir -p ${DEPLOY_DIR}
30+
fi
31+
32+
check_var_set WORKERS
33+
34+
echo DEPLOY_DIR ${DEPLOY_DIR}
35+
echo WORKERS ${WORKERS}
36+
37+
for WORKER in ${WORKERS}; do
38+
cat > ${DEPLOY_DIR}/${WORKER}_nncp_dns.yaml <<EOF_CAT
39+
apiVersion: nmstate.io/v1
40+
kind: NodeNetworkConfigurationPolicy
41+
metadata:
42+
labels:
43+
osp/interface: nncp-dns
44+
name: nncp-dns-${WORKER}
45+
spec:
46+
desiredState:
47+
dns-resolver:
48+
config:
49+
search: []
50+
server:
51+
- ${DNS_SERVER}
52+
EOF_CAT
53+
54+
done

0 commit comments

Comments
 (0)