Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
a8f7e9f7
Unverified
Commit
a8f7e9f7
authored
Dec 03, 2021
by
Derek Nola
Committed by
GitHub
Dec 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nighlty automation vagrant rework (#4574)
* Initial vagrantfile for createcluster test Signed-off-by:
Derek Nola
<
derek.nola@suse.com
>
parent
a0208058
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
1 deletion
+76
-1
.gitignore
.gitignore
+1
-1
Vagrantfile
tests/e2e/createcluster/Vagrantfile
+75
-0
No files found.
.gitignore
View file @
a8f7e9f7
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
/.tags
/.tags
/.idea
/.idea
/.trash-cache
/.trash-cache
/.vagrant
.vagrant/
/.kube
/.kube
/.cache
/.cache
/.docker
/.docker
...
...
tests/e2e/createcluster/Vagrantfile
0 → 100644
View file @
a8f7e9f7
NODE_ROLES
=
(
ENV
[
'NODE_ROLES'
]
||
[
"server-0"
,
"server-1"
,
"server-2"
,
"agent-0"
,
"agent-1"
])
NODE_BOXES
=
(
ENV
[
'NODE_BOXES'
]
||
[
'generic/ubuntu2004'
,
'generic/ubuntu2004'
,
'generic/ubuntu2004'
,
'generic/ubuntu2004'
,
'generic/ubuntu2004'
])
GITHUB_BRANCH
=
(
ENV
[
'GITHUB_BRANCH'
]
||
"master"
)
NODE_CPUS
=
(
ENV
[
'NODE_CPUS'
]
||
2
).
to_i
NODE_MEMORY
=
(
ENV
[
'NODE_MEMORY'
]
||
2048
).
to_i
# Virtualbox >= 6.1.28 require `/etc/vbox/network.conf` for expanded private networks
NETWORK_PREFIX
=
"10.10.10"
def
provision
(
vm
,
roles
,
role_num
,
node_num
)
vm
.
box
=
NODE_BOXES
[
node_num
]
vm
.
hostname
=
"
#{
roles
[
0
]
}
-
#{
role_num
}
"
# An expanded netmask is required to allow VM<-->VM communication, virtualbox defaults to /32
vm
.
network
"private_network"
,
ip:
"
#{
NETWORK_PREFIX
}
.
#{
100
+
node_num
}
"
,
netmask:
"255.255.255.0"
osConfigure
(
vm
)
vm
.
provision
"shell"
,
inline:
"curl -s -H 'Accept: application/vnd.github.v3.sha' 'https://api.github.com/repos/k3s-io/k3s/commits/
#{
GITHUB_BRANCH
}
' &> /tmp/k3s_commit"
vm
.
provision
"shell"
,
inline:
"ping -c 2 k3s.io"
if
roles
.
include?
(
"server"
)
&&
role_num
==
0
vm
.
provision
'k3s-install'
,
type:
'k3s'
,
run:
'once'
do
|
k3s
|
k3s
.
installer_url
=
'https://get.k3s.io'
k3s
.
args
=
%W[server --cluster-init --node-external-ip=
#{
NETWORK_PREFIX
}
.100 --flannel-iface=eth1]
k3s
.
env
=
%W[K3S_KUBECONFIG_MODE=0644 K3S_TOKEN=vagrant INSTALL_K3S_COMMIT=$(cat
\
/tmp/k3s_commit)]
k3s
.
config_mode
=
'0644'
# side-step https://github.com/k3s-io/k3s/issues/4321
end
elsif
roles
.
include?
(
"server"
)
&&
role_num
!=
0
vm
.
provision
'k3s-install'
,
type:
'k3s'
,
run:
'once'
do
|
k3s
|
k3s
.
installer_url
=
'https://get.k3s.io'
k3s
.
args
=
%W[server --server https://10.10.10.100:6443 --flannel-iface=eth1]
k3s
.
env
=
%W[K3S_KUBECONFIG_MODE=0644 K3S_TOKEN=vagrant INSTALL_K3S_COMMIT=$(cat
\
/tmp/k3s_commit)]
k3s
.
config_mode
=
'0644'
# side-step https://github.com/k3s-io/k3s/issues/4321
end
end
if
roles
.
include?
(
"agent"
)
vm
.
provision
'k3s-install'
,
type:
'k3s'
,
run:
'once'
do
|
k3s
|
k3s
.
installer_url
=
'https://get.k3s.io'
k3s
.
args
=
%w[agent --server https://10.10.10.100:6443 --flannel-iface=eth1]
k3s
.
env
=
%W[K3S_KUBECONFIG_MODE=0644 K3S_TOKEN=vagrant INSTALL_K3S_COMMIT=$(cat
\
/tmp/k3s_commit)]
k3s
.
config_mode
=
'0644'
# side-step https://github.com/k3s-io/k3s/issues/4321
end
end
end
def
osConfigure
(
vm
)
if
vm
.
box
.
include?
(
"ubuntu2004"
)
vm
.
provision
"shell"
,
inline:
"systemd-resolve --set-dns=8.8.8.8 --interface=eth0"
end
end
Vagrant
.
configure
(
"2"
)
do
|
config
|
config
.
vagrant
.
plugins
=
[
"vagrant-k3s"
]
config
.
vm
.
provider
"virtualbox"
do
|
v
|
v
.
cpus
=
NODE_CPUS
v
.
memory
=
NODE_MEMORY
end
# Must iterate on the index, vagrant does not understand iterating
# over the node roles themselves
NODE_ROLES
.
length
.
times
do
|
i
|
name
=
NODE_ROLES
[
i
]
config
.
vm
.
define
name
do
|
node
|
roles
=
name
.
split
(
"-"
,
-
1
)
role_num
=
roles
.
pop
.
to_i
provision
(
node
.
vm
,
roles
,
role_num
,
i
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment