-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add variable options to pass a map of host IPs to secondary IPs - Add variable to attach network definition annotations to pods - Add playbook for creating networkAttachmentDefinitions Signed-off-by: Aaron Wilson <[email protected]>
- Loading branch information
Showing
19 changed files
with
167 additions
and
3 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,19 @@ | ||
// Package cmn provides utilities for common AIS cluster resources | ||
/* | ||
* Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. | ||
*/ | ||
package cmn | ||
|
||
import ( | ||
aisv1 "github.com/ais-operator/api/v1beta1" | ||
nadv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1" | ||
) | ||
|
||
func ParseAnnotations(ais *aisv1.AIStore) map[string]string { | ||
if ais.Spec.NetAttachment != nil { | ||
return map[string]string{ | ||
nadv1.NetworkAttachmentAnnot: *ais.Spec.NetAttachment, | ||
} | ||
} | ||
return nil | ||
} |
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
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,16 @@ | ||
--- | ||
- hosts: "controller" | ||
gather_facts: false | ||
vars_files: | ||
- "vars/multihome.yml" | ||
pre_tasks: | ||
- name: Check cluster variable | ||
fail: | ||
msg: "No cluster specified!" | ||
when: cluster is undefined | ||
- name: Check network_attachment variable | ||
fail: | ||
msg: "`network_attachment` name must be provided!" | ||
when: network_attachment is undefined or network_attachment | length == 0 | ||
roles: | ||
- create_network_definition |
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
9 changes: 9 additions & 0 deletions
9
playbooks/roles/create_network_definition/files/create-network-definition.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,9 @@ | ||
#!/bin/bash | ||
export NAD_NAME="$NAME" | ||
export NAD_NAMESPACE="$NAMESPACE" | ||
export NAD_IFACE="$INTERFACE" | ||
source_dir=$(dirname "${BASH_SOURCE[0]}") | ||
|
||
envsubst < "${source_dir}"/nad.template.yaml > /tmp/network-attachment-def.yaml | ||
kubectl apply -f /tmp/network-attachment-def.yaml | ||
rm /tmp/network-attachment-def.yaml |
22 changes: 22 additions & 0 deletions
22
playbooks/roles/create_network_definition/files/nad.template.yaml
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,22 @@ | ||
apiVersion: "k8s.cni.cncf.io/v1" | ||
kind: NetworkAttachmentDefinition | ||
metadata: | ||
name: $NAD_NAME | ||
namespace: $NAD_NAMESPACE | ||
spec: | ||
config: '{ | ||
"cniVersion": "0.3.0", | ||
"type": "macvlan", | ||
"master": "$NAD_IFACE", | ||
"mode": "bridge", | ||
"ipam": { | ||
"type": "host-local", | ||
"subnet": "192.168.1.0/24", | ||
"rangeStart": "192.168.1.200", | ||
"rangeEnd": "192.168.1.216", | ||
"routes": [ | ||
{ "dst": "0.0.0.0/0" } | ||
], | ||
"gateway": "192.168.1.1" | ||
} | ||
}' |
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,16 @@ | ||
- name: Create namespace if it does not exist | ||
shell: "kubectl create ns {{ cluster }} || true" | ||
register: namespaceout | ||
changed_when: "'created' in namespaceout.stdout" | ||
|
||
- name: Copy network attachment definition files | ||
copy: | ||
src: "{{ item }}" | ||
dest: "/tmp" | ||
mode: 0777 | ||
loop: | ||
- "create-network-definition.sh" | ||
- "nad.template.yaml" | ||
|
||
- name: Apply network attachment definition | ||
shell: "NAMESPACE={{ cluster }} NAME={{ network_attachment }} INTERFACE={{ network_interface }} /tmp/create-network-definition.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,13 @@ | ||
# Map primary host address to list of all addresses available for each host in the format: | ||
# primary1=primary1,secondary1 primary2=primary2,secondary2 | ||
# Example: | ||
# hostname_map: "10.51.248.22=10.51.248.22,10.51.248.55 10.51.248.25=10.51.248.25,10.51.248.52 10.51.248.28=10.51.248.28,10.51.248.61" | ||
# TODO: Pull this from ansible inventory | ||
hostname_map: "" | ||
|
||
# Name of the Network Attachment Definition to be referenced as an annotation by the AIS stateful set | ||
# See the multus example: https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/docs/quickstart.md#storing-a-configuration-as-a-custom-resource | ||
network_attachment: "" | ||
|
||
# Name of the interface for which to create a network attachment definition | ||
network_interface: "" |