Skip to content

Commit

Permalink
expose docker engine, implement delete operations (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
milesstoetzner authored Sep 5, 2024
1 parent 627c188 commit 3c6d29d
Show file tree
Hide file tree
Showing 59 changed files with 4,152 additions and 1,028 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ topology_template:
technology: terraform
properties:
- machine_name: unfurl-technology-boutique
- ports: ['80', '9100']
- ports: ['80', '2375', '9100']
- flavor:
value: m1.medium
conditions: {equal: [{variability_input: tier}, MEDIUM]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ topology_template:
technology: terraform
properties:
- machine_name: unfurl-technology-boutique
- ports: ['80', '9100']
- ports: ['80', '2375', '9100']
- flavor:
value: m1.medium
conditions: {equal: [{variability_input: tier}, MEDIUM]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,25 @@ node_types:
- '--become'
- '--key-file={{ SELF.os_ssh_key_file }}'
- '--user={{ SELF.os_ssh_user }}'
delete: exit 0
delete:
implementation:
primary: Ansible
operation_host: HOST
environment:
ANSIBLE_HOST_KEY_CHECKING: 'False'
inputs:
playbook:
q:
- name: wait for ssh
wait_for_connection:
- name: stop container
community.docker.docker_container:
name: '{{ SELF.application_name }}'
state: absent
playbookArgs:
- '--become'
- '--key-file={{ SELF.os_ssh_key_file }}'
- '--user={{ SELF.os_ssh_user }}'
node.agent~service.application#docker.image::[email protected]:
derived_from: node.agent
metadata:
Expand Down Expand Up @@ -267,7 +285,36 @@ node_types:
selector:
app: '{{ SELF.application_name }}'
type: ClusterIP
delete: exit 0
delete:
implementation:
primary: Ansible
operation_host: ORCHESTRATOR
environment:
K8S_AUTH_HOST:
eval: .::k8s_host
K8S_AUTH_SSL_CA_CERT:
eval: .::k8s_ca_cert_file
K8S_AUTH_CERT_FILE:
eval: .::k8s_client_cert_file
K8S_AUTH_KEY_FILE:
eval: .::k8s_client_key_file
inputs:
playbook:
q:
- name: delete service
kubernetes.core.k8s:
state: absent
api_version: v1
kind: Service
namespace: default
name: '{{ SELF.application_name }}'
- name: delete deployment
kubernetes.core.k8s:
state: absent
api_version: app/v1
kind: Deployment
namespace: default
name: '{{ SELF.application_name }}'
node.agent~service.application#tar.archive::ansible@*->remote.machine:
derived_from: node.agent
metadata:
Expand Down Expand Up @@ -2815,28 +2862,81 @@ node_types:
app: '{{ SELF.application_name }}'
type: ClusterIP
- name: apply manifest
ansible.builtin.shell: kubectl apply -f {{ manifest.path }}
ansible.builtin.shell: kubectl --server {{ SELF.k8s_host }} --certificate-authority {{ SELF.k8s_ca_cert_file }} --client-certificate {{ SELF.k8s_client_cert_file }} --client-key {{ SELF.k8s_client_key_file }} apply -f {{ manifest.path }}
args:
executable: /usr/bin/bash
- name: wait for deployment
ansible.builtin.shell: kubectl rollout status deployment/{{ SELF.application_name }} --timeout 60s
ansible.builtin.shell: kubectl --server {{ SELF.k8s_host }} --certificate-authority {{ SELF.k8s_ca_cert_file }} --client-certificate {{ SELF.k8s_client_cert_file }} --client-key {{ SELF.k8s_client_key_file }} rollout status deployment/{{ SELF.application_name }} --timeout 60s
args:
executable: /usr/bin/bash
delete:
implementation:
primary: Ansible
operation_host: ORCHESTRATOR
inputs:
playbook:
q:
- name: touch manifest
register: manifest
ansible.builtin.tempfile:
suffix: '{{ SELF.application_name }}.application.manifest.yaml'
- name: create manifest
ansible.builtin.copy:
dest: '{{ manifest.path }}'
content: |
{{ deployment | to_yaml }}
---
{{ service | to_yaml }}
vars:
deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: '{{ SELF.application_name }}'
namespace: default
spec:
selector:
matchLabels:
app: '{{ SELF.application_name }}'
template:
metadata:
labels:
app: '{{ SELF.application_name }}'
spec:
containers:
- image: '{{ ".artifacts::docker_image::file" | eval }}'
name: '{{ SELF.application_name }}'
env: []
ports:
- containerPort: '{{ SELF.application_port }}'
service:
apiVersion: v1
kind: Service
metadata:
name: '{{ SELF.application_name }}'
namespace: default
spec:
ports:
- name: '{{ SELF.application_protocol }}'
port: '{{ SELF.application_port }}'
targetPort: '{{ SELF.application_port }}'
selector:
app: '{{ SELF.application_name }}'
type: ClusterIP
- name: unapply manifest
ansible.builtin.shell: kubectl --server {{ SELF.k8s_host }} --certificate-authority {{ SELF.k8s_ca_cert_file }} --client-certificate {{ SELF.k8s_client_cert_file }} --client-key {{ SELF.k8s_client_key_file }} delete -f {{ manifest.path }}
args:
executable: /usr/bin/bash
delete: exit 0
node.agent~service.application#docker.image::[email protected]>remote.machine:
derived_from: node.agent
metadata:
vintner_generated: 'true'
vintner_orchestrator: unfurl
properties:
os_ssh_user:
type: string
default:
get_input: os_ssh_user
os_ssh_key_file:
os_ssh_host:
type: string
default:
get_input: os_ssh_key_file
eval: .::.requirements::[.name=host]::.target::management_address
attributes:
application_address:
type: string
Expand All @@ -2847,14 +2947,10 @@ node_types:
create:
implementation:
primary: Ansible
operation_host: HOST
environment:
ANSIBLE_HOST_KEY_CHECKING: 'False'
operation_host: ORCHESTRATOR
inputs:
playbook:
q:
- name: wait for ssh
wait_for_connection:
- name: touch compose
register: compose
ansible.builtin.tempfile:
Expand All @@ -2876,8 +2972,35 @@ node_types:
ansible.builtin.shell: docker compose -f {{ compose.path }} up -d
args:
executable: /usr/bin/bash
playbookArgs:
- '--become'
- '--key-file={{ SELF.os_ssh_key_file }}'
- '--user={{ SELF.os_ssh_user }}'
delete: exit 0
environment:
DOCKER_HOST: '{{ SELF.os_ssh_host }}'
delete:
implementation:
primary: Ansible
operation_host: ORCHESTRATOR
inputs:
playbook:
q:
- name: touch compose
register: compose
ansible.builtin.tempfile:
suffix: '{{ SELF.application_name }}.compose.yaml'
- name: create compose
ansible.builtin.copy:
dest: '{{ compose.path }}'
content: '{{ manifest | to_yaml }}'
vars:
manifest:
name: '{{ SELF.application_name }}'
services:
application:
container_name: '{{ SELF.application_name }}'
image: '{{ ".artifacts::docker_image::file" | eval }}'
network_mode: host
environment: {}
- name: apply compose
ansible.builtin.shell: docker compose -f {{ compose.path }} down
args:
executable: /usr/bin/bash
environment:
DOCKER_HOST: '{{ SELF.os_ssh_host }}'
Loading

0 comments on commit 3c6d29d

Please sign in to comment.