-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate KubeSecondaryDNS as part of CNAO. "core-dns-image" can be used in order to generate a CSV manifest with custom image. Signed-off-by: Or Shoval <[email protected]>
- Loading branch information
Showing
16 changed files
with
427 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
automation/check-patch.e2e-kube-secondary-dns-functests.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -xeuE | ||
|
||
# This script should be able to execute kube secondary dns | ||
# functional tests against Kubernetes cluster with | ||
# CNAO built with latest changes, on any | ||
# environment with basic dependencies listed in | ||
# check-patch.packages installed and docker running. | ||
# | ||
# yum -y install automation/check-patch.packages | ||
# automation/check-patch.e2e-kube-secondary-dns-functests.sh | ||
|
||
teardown() { | ||
cp $(find . -name "*junit*.xml") $ARTIFACTS || true | ||
rm -rf "${TMP_COMPONENT_PATH}" | ||
cd ${TMP_PROJECT_PATH} | ||
make cluster-down | ||
} | ||
|
||
main() { | ||
# Setup CNAO and artifacts temp directory | ||
source automation/check-patch.setup.sh | ||
cd ${TMP_PROJECT_PATH} | ||
|
||
# Spin-up ephemeral cluster with latest CNAO | ||
# this script also exports KUBECONFIG, and fetch $COMPONENT repository | ||
COMPONENT="kube-secondary-dns" source automation/components-functests.setup.sh | ||
|
||
trap teardown EXIT | ||
|
||
cd ${TMP_COMPONENT_PATH} | ||
make create-nodeport | ||
echo "Run kube-secondary-dns functional tests" | ||
make functest | ||
} | ||
|
||
[[ "${BASH_SOURCE[0]}" == "$0" ]] && main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: {{ .Namespace }} | ||
--- | ||
apiVersion: v1 | ||
data: | ||
DOMAIN: {{ .Domain }} | ||
NAME_SERVER_IP: {{ .NameServerIp }} | ||
Corefile: | | ||
.:53 { | ||
auto { | ||
directory /zones db\.(.*) {1} | ||
reload 45s | ||
} | ||
reload | ||
log | ||
} | ||
kind: ConfigMap | ||
metadata: | ||
name: secondary-dns | ||
namespace: {{ .Namespace }} | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: secondary | ||
rules: | ||
- apiGroups: | ||
- kubevirt.io | ||
resources: | ||
- virtualmachineinstances | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: secondary | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: secondary | ||
subjects: | ||
- kind: ServiceAccount | ||
name: secondary | ||
namespace: {{ .Namespace }} | ||
--- | ||
kind: ServiceAccount | ||
apiVersion: v1 | ||
metadata: | ||
name: secondary | ||
namespace: {{ .Namespace }} | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
k8s-app: secondary-dns | ||
name: secondary-dns | ||
namespace: {{ .Namespace }} | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
k8s-app: secondary-dns | ||
template: | ||
metadata: | ||
labels: | ||
k8s-app: secondary-dns | ||
annotations: | ||
kubectl.kubernetes.io/default-container: status-monitor | ||
spec: | ||
serviceAccountName: secondary | ||
containers: | ||
- args: | ||
- -conf | ||
- /etc/coredns/Corefile | ||
image: {{ .CoreDNSImage }} | ||
imagePullPolicy: {{ .ImagePullPolicy }} | ||
name: secondary-dns | ||
ports: | ||
- containerPort: 53 | ||
name: dns | ||
protocol: UDP | ||
resources: | ||
limits: | ||
memory: 170Mi | ||
requests: | ||
cpu: 100m | ||
memory: 70Mi | ||
volumeMounts: | ||
- name: config-volume | ||
mountPath: /etc/coredns | ||
readOnly: true | ||
- name: secdns-zones | ||
mountPath: /zones | ||
readOnly: true | ||
- name: status-monitor | ||
image: {{ .KubeSecondaryDNSImage }} | ||
volumeMounts: | ||
- name: secdns-zones | ||
mountPath: /zones | ||
env: | ||
- name: DOMAIN | ||
valueFrom: | ||
configMapKeyRef: | ||
name: secondary-dns | ||
key: DOMAIN | ||
- name: NAME_SERVER_IP | ||
valueFrom: | ||
configMapKeyRef: | ||
name: secondary-dns | ||
key: NAME_SERVER_IP | ||
imagePullPolicy: {{ .ImagePullPolicy }} | ||
priorityClassName: system-cluster-critical | ||
restartPolicy: Always | ||
terminationGracePeriodSeconds: 1 | ||
volumes: | ||
- name: config-volume | ||
configMap: | ||
defaultMode: 420 | ||
items: | ||
- key: Corefile | ||
path: Corefile | ||
name: secondary-dns | ||
- name: secdns-zones | ||
emptyDir: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -xeo pipefail | ||
|
||
source hack/components/yaml-utils.sh | ||
source hack/components/git-utils.sh | ||
source hack/components/docker-utils.sh | ||
|
||
function __parametize_by_object() { | ||
for f in ./*; do | ||
case "${f}" in | ||
./Namespace_secondary.yaml) | ||
yaml-utils::update_param ${f} metadata.name '{{ .Namespace }}' | ||
yaml-utils::remove_single_quotes_from_yaml ${f} | ||
;; | ||
./ConfigMap_secondary-dns.yaml) | ||
yaml-utils::update_param ${f} metadata.namespace '{{ .Namespace }}' | ||
yaml-utils::update_param ${f} data.DOMAIN '{{ .Domain }}' | ||
yaml-utils::update_param ${f} data.NAME_SERVER_IP '{{ .NameServerIp }}' | ||
yaml-utils::remove_single_quotes_from_yaml ${f} | ||
;; | ||
./ClusterRoleBinding_secondary.yaml) | ||
yaml-utils::update_param ${f} subjects[0].namespace '{{ .Namespace }}' | ||
yaml-utils::remove_single_quotes_from_yaml ${f} | ||
;; | ||
./Deployment_secondary-dns.yaml) | ||
yaml-utils::update_param ${f} metadata.namespace '{{ .Namespace }}' | ||
yaml-utils::update_param ${f} spec.template.spec.containers[0].image '{{ .CoreDNSImage }}' | ||
yaml-utils::update_param ${f} spec.template.spec.containers[1].image '{{ .KubeSecondaryDNSImage }}' | ||
yaml-utils::set_param ${f} spec.template.spec.containers[0].imagePullPolicy '{{ .ImagePullPolicy }}' | ||
yaml-utils::set_param ${f} spec.template.spec.containers[1].imagePullPolicy '{{ .ImagePullPolicy }}' | ||
yaml-utils::remove_single_quotes_from_yaml ${f} | ||
;; | ||
./ServiceAccount_secondary.yaml) | ||
yaml-utils::update_param ${f} metadata.namespace '{{ .Namespace }}' | ||
yaml-utils::remove_single_quotes_from_yaml ${f} | ||
;; | ||
esac | ||
done | ||
} | ||
|
||
echo 'Bumping kube-secondary-dns' | ||
KUBE_SECONDARY_DNS_URL=$(yaml-utils::get_component_url kube-secondary-dns) | ||
KUBE_SECONDARY_DNS_COMMIT=$(yaml-utils::get_component_commit kube-secondary-dns) | ||
KUBE_SECONDARY_DNS_REPO=$(yaml-utils::get_component_repo ${KUBE_SECONDARY_DNS_URL}) | ||
|
||
TEMP_DIR=$(git-utils::create_temp_path kube-secondary-dns) | ||
trap "rm -rf ${TEMP_DIR}" EXIT | ||
KUBE_SECONDARY_DNS_PATH=${TEMP_DIR}/${KUBE_SECONDARY_DNS_REPO} | ||
|
||
echo 'Fetch kube-secondary-dns sources' | ||
git-utils::fetch_component ${KUBE_SECONDARY_DNS_PATH} ${KUBE_SECONDARY_DNS_URL} ${KUBE_SECONDARY_DNS_COMMIT} | ||
|
||
echo 'Adjust kube-secondary-dns to CNAO' | ||
( | ||
cd ${KUBE_SECONDARY_DNS_PATH} | ||
mkdir -p config/cnao | ||
cp manifests/secondarydns.yaml config/cnao | ||
|
||
echo 'Split manifest per object' | ||
cd config/cnao | ||
$(yaml-utils::split_yaml_by_seperator . secondarydns.yaml) | ||
|
||
rm secondarydns.yaml | ||
$(yaml-utils::rename_files_by_object .) | ||
|
||
echo 'parametize manifests by object' | ||
__parametize_by_object | ||
|
||
echo 'rejoin sub-manifests to a final manifest' | ||
cat Namespace_secondary.yaml \ | ||
ConfigMap_secondary-dns.yaml \ | ||
ClusterRole_secondary.yaml \ | ||
ClusterRoleBinding_secondary.yaml \ | ||
ServiceAccount_secondary.yaml \ | ||
Deployment_secondary-dns.yaml > secondarydns.yaml | ||
) | ||
|
||
echo 'copy manifests' | ||
rm -rf data/kube-secondary-dns/* | ||
cp ${KUBE_SECONDARY_DNS_PATH}/config/cnao/secondarydns.yaml data/kube-secondary-dns | ||
|
||
echo 'Get kube-secondary-dns image name and update it under CNAO' | ||
KUBE_SECONDARY_DNS_TAG=$(git-utils::get_component_tag ${KUBE_SECONDARY_DNS_PATH}) | ||
KUBE_SECONDARY_DNS_IMAGE=ghcr.io/kubevirt/kubesecondarydns | ||
KUBE_SECONDARY_DNS_IMAGE_TAGGED=${KUBE_SECONDARY_DNS_IMAGE}:${KUBE_SECONDARY_DNS_TAG} | ||
KUBE_SECONDARY_DNS_IMAGE_DIGEST="$(docker-utils::get_image_digest "${KUBE_SECONDARY_DNS_IMAGE_TAGGED}" "${KUBE_SECONDARY_DNS_IMAGE}")" | ||
|
||
sed -i -r "s#\"${KUBE_SECONDARY_DNS_IMAGE}(@sha256)?:.*\"#\"${KUBE_SECONDARY_DNS_IMAGE_DIGEST}\"#" pkg/components/components.go | ||
sed -i -r "s#\"${KUBE_SECONDARY_DNS_IMAGE}(@sha256)?:.*\"#\"${KUBE_SECONDARY_DNS_IMAGE_DIGEST}\"#" test/releases/${CNAO_VERSION}.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.