Commit c1599330 authored by Spiros Koulouzis's avatar Spiros Koulouzis

added create k8s

parent e9d0cc2e
...@@ -76,6 +76,10 @@ node_types: ...@@ -76,6 +76,10 @@ node_types:
inputs: inputs:
inventory_file: k8s_hosts inventory_file: k8s_hosts
playbook: https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/ansible_playbooks/install_k8s.yml 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: #tosca.nodes.ARTICONF.Orchestrator.Swarm:
......
---
- 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
...@@ -2,8 +2,14 @@ ...@@ -2,8 +2,14 @@
become: yes become: yes
tasks: tasks:
- name: replace DNS #- name: replace DNS
shell: sed -i "s/nameserver.*/nameserver 8.8.8.8/g" /etc/resolv.conf #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 - name: Update and upgrade apt packages
become: true become: true
......
...@@ -64,7 +64,7 @@ def write_ansible_files(vms, interfaces, tmp_path): ...@@ -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_common_args=\'-o StrictHostKeyChecking=no\'', file=k8s_hosts_file)
print('ansible_ssh_user=' + ansible_ssh_user, 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) r = requests.get(image_url)
with open(tmp_path + "/playbook.yml", 'wb') as f: with open(tmp_path + "/playbook.yml", 'wb') as f:
f.write(r.content) f.write(r.content)
...@@ -78,8 +78,8 @@ def run(interfaces, vms): ...@@ -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, p = Popen(["ansible-playbook", "-i", tmp_path + "/k8s_hosts", tmp_path + "/playbook.yml"], stdin=PIPE, stdout=PIPE,
stderr=PIPE) stderr=PIPE)
output, err = p.communicate() output, err = p.communicate()
print(output) print(output.decode('utf-8'))
print(err) print(err.decode('utf-8'))
rc = p.returncode rc = p.returncode
return tmp_path return tmp_path
......
...@@ -9,9 +9,6 @@ import org.springframework.http.ResponseEntity; ...@@ -9,9 +9,6 @@ import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import javax.servlet.http.HttpServletRequest; 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 nl.uva.sne.drip.service.DRIPService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -44,10 +41,15 @@ public class DeployerApiController implements DeployerApi { ...@@ -44,10 +41,15 @@ public class DeployerApiController implements DeployerApi {
String accept = request.getHeader("Accept"); String accept = request.getHeader("Accept");
if (accept != null && accept.contains("")) { if (accept != null && accept.contains("")) {
try {
dripService.setRequestQeueName(queueName); dripService.setRequestQeueName(queueName);
String planedYemplateId = dripService.deploy(id); String planedYemplateId = dripService.deploy(id);
return new ResponseEntity<>(planedYemplateId, HttpStatus.OK); return new ResponseEntity<>(planedYemplateId, HttpStatus.OK);
} catch (Exception ex) {
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
} }
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
} }
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <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="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment