Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
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
UvA
CONF
Commits
c1599330
Commit
c1599330
authored
5 years ago
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added create k8s
parent
e9d0cc2e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
106 additions
and
13 deletions
+106
-13
interfaces.yml
TOSCA/types/interfaces.yml
+1
-1
nodes.yaml
TOSCA/types/nodes.yaml
+4
-0
create_k8s.yml
ansible_playbooks/create_k8s.yml
+78
-0
install_k8s.yml
ansible_playbooks/install_k8s.yml
+8
-2
ansible_service.py
drip-deployer/service/ansible_service.py
+3
-3
DeployerApiController.java
.../main/java/nl/uva/sne/drip/api/DeployerApiController.java
+8
-6
workspace.xml
drip-planner/.idea/workspace.xml
+4
-1
No files found.
TOSCA/types/interfaces.yml
View file @
c1599330
...
...
@@ -74,7 +74,7 @@ interface_types:
required
:
false
default
:
https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/ansible_playbooks/install_k8s.yml
install
:
description
:
install Kubernetes
description
:
install Kubernetes
k8s_scale
:
description
:
Set the number of replicas for a Deployment, ReplicaSet, or Replication Controller, or the parallelism attribute of a Job.
k8s_create
:
...
...
This diff is collapsed.
Click to expand it.
TOSCA/types/nodes.yaml
View file @
c1599330
...
...
@@ -76,6 +76,10 @@ node_types:
inputs
:
inventory_file
:
k8s_hosts
playbook
:
https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/ansible_playbooks/install_k8s.yml
create
:
inputs
:
inventory_file
:
k8s_hosts
playbook
:
https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/ansible_playbooks/install_k8s.yml
#tosca.nodes.ARTICONF.Orchestrator.Swarm:
...
...
This diff is collapsed.
Click to expand it.
ansible_playbooks/create_k8s.yml
0 → 100644
View file @
c1599330
---
-
hosts
:
k8-master
tasks
:
-
name
:
disable swap
become
:
yes
shell
:
swapoff -a
-
name
:
kubeadm init
shell
:
kubeadm init
become
:
yes
-
name
:
Create directory .kube
file
:
path
:
$HOME/.kube
state
:
directory
recurse
:
yes
-
name
:
copy admin.conf
become
:
yes
copy
:
src
:
/etc/kubernetes/admin.conf
dest
:
"
/home/{{
ansible_ssh_user
}}/.kube/config"
owner
:
"
{{
ansible_ssh_user
}}"
group
:
"
{{
ansible_ssh_user
}}"
remote_src
:
True
-
name
:
set bridge
sysctl
:
name
:
net.bridge.bridge-nf-call-iptables
value
:
1
state
:
present
become
:
yes
-
name
:
kubeadm set weave
shell
:
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
-
name
:
kubectl taint nodes
shell
:
kubectl taint nodes --all node-role.kubernetes.io/master-
-
name
:
join cmd
shell
:
kubeadm token create --print-join-command
register
:
k8_join_cmd
-
name
:
Add join cmd to dummy host
add_host
:
name
:
"
k8s_join_cmd_holder"
cmd
:
"
{{
k8_join_cmd.stdout
}}"
-
name
:
debug
:
msg
:
"
Join
command
is
{{
hostvars['k8s_join_cmd_holder']['cmd']
}}"
-
hosts
:
worker
tasks
:
-
name
:
disable swap
become
:
yes
shell
:
swapoff -a
-
name
:
print join cmd
debug
:
msg
:
"
[Worker]
K8S_TOKEN_HOLDER
K8S
token
is
{{
hostvars['k8s_join_cmd_holder']['cmd']
}}"
-
name
:
join
shell
:
"
{{
hostvars['k8s_join_cmd_holder']['cmd']
}}"
become
:
yes
-
hosts
:
k8-master
tasks
:
-
name
:
get nodes
shell
:
kubectl get nodes
register
:
nodes_out
-
name
:
print nodes
debug
:
var
:
nodes_out
This diff is collapsed.
Click to expand it.
ansible_playbooks/install_k8s.yml
View file @
c1599330
...
...
@@ -2,8 +2,14 @@
become
:
yes
tasks
:
-
name
:
replace DNS
shell
:
sed -i "s/nameserver.*/nameserver 8.8.8.8/g" /etc/resolv.conf
#- name: replace DNS
#shell: sed -i "s/nameserver.*/nameserver 8.8.8.8/g"
-
name
:
Replace a localhost entry with our own
lineinfile
:
path
:
/etc/resolv.conf
regexp
:
'
nameserver.*'
line
:
nameserver 8.8.8.8
-
name
:
Update and upgrade apt packages
become
:
true
...
...
This diff is collapsed.
Click to expand it.
drip-deployer/service/ansible_service.py
View file @
c1599330
...
...
@@ -64,7 +64,7 @@ def write_ansible_files(vms, interfaces, tmp_path):
print
(
'ansible_ssh_common_args=
\'
-o StrictHostKeyChecking=no
\'
'
,
file
=
k8s_hosts_file
)
print
(
'ansible_ssh_user='
+
ansible_ssh_user
,
file
=
k8s_hosts_file
)
image_url
=
interfaces
[
'
Standard'
][
'create
'
][
'inputs'
][
'playbook'
]
image_url
=
interfaces
[
'
Kubernetes'
][
'install
'
][
'inputs'
][
'playbook'
]
r
=
requests
.
get
(
image_url
)
with
open
(
tmp_path
+
"/playbook.yml"
,
'wb'
)
as
f
:
f
.
write
(
r
.
content
)
...
...
@@ -78,8 +78,8 @@ def run(interfaces, vms):
p
=
Popen
([
"ansible-playbook"
,
"-i"
,
tmp_path
+
"/k8s_hosts"
,
tmp_path
+
"/playbook.yml"
],
stdin
=
PIPE
,
stdout
=
PIPE
,
stderr
=
PIPE
)
output
,
err
=
p
.
communicate
()
print
(
output
)
print
(
err
)
print
(
output
.
decode
(
'utf-8'
)
)
print
(
err
.
decode
(
'utf-8'
)
)
rc
=
p
.
returncode
return
tmp_path
...
...
This diff is collapsed.
Click to expand it.
drip-manager/src/main/java/nl/uva/sne/drip/api/DeployerApiController.java
View file @
c1599330
...
...
@@ -9,9 +9,6 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.logging.Level
;
import
nl.uva.sne.drip.service.DRIPService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -44,9 +41,14 @@ public class DeployerApiController implements DeployerApi {
String
accept
=
request
.
getHeader
(
"Accept"
);
if
(
accept
!=
null
&&
accept
.
contains
(
""
))
{
dripService
.
setRequestQeueName
(
queueName
);
String
planedYemplateId
=
dripService
.
deploy
(
id
);
return
new
ResponseEntity
<>(
planedYemplateId
,
HttpStatus
.
OK
);
try
{
dripService
.
setRequestQeueName
(
queueName
);
String
planedYemplateId
=
dripService
.
deploy
(
id
);
return
new
ResponseEntity
<>(
planedYemplateId
,
HttpStatus
.
OK
);
}
catch
(
Exception
ex
)
{
return
new
ResponseEntity
<>(
HttpStatus
.
INTERNAL_SERVER_ERROR
);
}
}
return
new
ResponseEntity
<>(
HttpStatus
.
NOT_IMPLEMENTED
);
...
...
This diff is collapsed.
Click to expand it.
drip-planner/.idea/workspace.xml
View file @
c1599330
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"e478ccae-5352-4e8e-9efb-3f5cda44e877"
name=
"Default Changelist"
comment=
""
/>
<list
default=
"true"
id=
"e478ccae-5352-4e8e-9efb-3f5cda44e877"
name=
"Default Changelist"
comment=
""
>
<change
beforePath=
"$PROJECT_DIR$/../TOSCA/types/interfaces.yml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../TOSCA/types/interfaces.yml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/api/DeployerApiController.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/api/DeployerApiController.java"
afterDir=
"false"
/>
</list>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
<option
name=
"HIGHLIGHT_NON_ACTIVE_CHANGELIST"
value=
"false"
/>
...
...
This diff is collapsed.
Click to expand it.
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