Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: (IAC-1102) Move "deploy manifest" feature for experimental branch to main #549

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 34 additions & 87 deletions roles/vdm/tasks/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

---
- name: Deploy - Apply SAS Viya deployment
- name: Deploy - Apply SAS Viya deployment - Deployment Operator
kubernetes.core.k8s:
src: "{{ DEPLOY_DIR }}/sasdeployment.yaml"
state: present
Expand All @@ -15,110 +15,44 @@
- update
- cas-onboard

- name: Deploy - Apply SAS Viya deployment
- name: Deploy - Apply SAS Viya deployment - sas-orchestration
when:
- not V4_DEPLOYMENT_OPERATOR_ENABLED
tags:
- install
- update
- cas-onboard
block:
- name: Deploy - Gather all resource files
find:
paths: "{{ ORCHESTRATION_TOOLING_INSTALL_MANIFESTS_DIRECTORY }}"
patterns: "*.yaml"
register: manifests
- name: Deploy - Gather SAS Viya deployment resource files
find:
paths: "{{ ORCHESTRATION_TOOLING_INSTALL_MANIFESTS_DIRECTORY }}"
patterns: "*.yaml"
contains: "^kind: SASDeployment"
register: deployment_manifests
failed_when:
- ( deployment_manifests.files | length ) != 1
- name: Deploy - Apply supporting resources
kubernetes.core.k8s:
src: "{{ item.path }}"
state: present
namespace: "{{ NAMESPACE }}"
kubeconfig: "{{ KUBECONFIG }}"
with_items:
- "{{ manifests.files | difference(deployment_manifests.files) }}"
- name: Orchestration - Create orchestration tooling work directory
file:
path: "{{ ORCHESTRATION_TOOLING_DIRECTORY }}/work"
state: directory
- name: Deploy - Deploy SAS Viya
- name: Deploy - Deploy SAS Viya - sas-orchestration - Docker
environment:
PATH: "{{ ORCHESTRATION_TOOLING_PATH + ':' + env_path }}"
KUBECONFIG: "{{ KUBECONFIG }}"
WORK_DIRECTORY: "{{ ORCHESTRATION_TOOLING_DIRECTORY }}/work"
EXPERIMENTAL_FEATURE_DEPLOY_MANIFEST: "true"
command: |
orchestration deploy
orchestration deploy manifest
--namespace "{{ NAMESPACE }}"
--sas-deployment-cr "{{ item.path }}"
--manifest "{{ DEPLOY_DIR }}/site.yaml"
--deployment-dir "{{ DEPLOY_DIR }}/sas-bases"
args:
chdir: "{{ ORCHESTRATION_TOOLING_DIRECTORY }}"
with_items:
- "{{ deployment_manifests.files }}"
when:
- deployment_tooling == "docker"
- not V4_CFG_BELOW_THE_LINE
- name: Deploy BLT - Deploy SAS Viya
environment:
PATH: "{{ ORCHESTRATION_TOOLING_PATH + ':' + env_path }}"
KUBECONFIG: "{{ KUBECONFIG }}"
WORK_DIRECTORY: "{{ ORCHESTRATION_TOOLING_DIRECTORY }}/work"
EXPERIMENTAL_FEATURE_LOCAL_DEPLOYMENT_ASSETS: true
command: |
orchestration deploy
--namespace "{{ NAMESPACE }}"
--user-content "{{ DEPLOY_DIR }}"
--local-deployment-assets
args:
chdir: "{{ ORCHESTRATION_TOOLING_DIRECTORY }}"
with_items:
- "{{ deployment_manifests.files }}"
when:
- deployment_tooling == "docker"
- V4_CFG_BELOW_THE_LINE
- name: Deploy - Deploy SAS Viya
ansible.builtin.shell: >
docker run --rm
--user="{{ UID_GID }}"
--name "orchestration_{{ lookup('password', '/dev/null chars=ascii_lowercase length=8') }}"
--env KUBECONFIG="/config/kubeconfig"
--env WORK_DIRECTORY="/tmp/work"
--volume "{{ ORCHESTRATION_TOOLING_INSTALL_MANIFESTS_DIRECTORY }}:/manifests"
--volume "{{ KUBECONFIG }}:/config/kubeconfig"
"{{ V4_CFG_CR_HOST }}/{{ ORCHESTRATION_IMAGE }}"
deploy
--namespace {{ NAMESPACE }}
--sas-deployment-cr {{ item.path | replace(ORCHESTRATION_TOOLING_DIRECTORY, '/') }}
with_items:
- "{{ deployment_manifests.files }}"
when:
- deployment_tooling == "ansible"
- not V4_CFG_BELOW_THE_LINE
- name: Deploy BLT - Deploy SAS Viya
- name: Deploy - Deploy SAS Viya - sas-orchestration - Ansible
ansible.builtin.shell: >
docker run --rm
--user="{{ UID_GID }}"
--name "orchestration_{{ lookup('password', '/dev/null chars=ascii_lowercase length=8') }}"
--env KUBECONFIG="/config/kubeconfig"
--env WORK_DIRECTORY="/tmp/work"
--env EXPERIMENTAL_FEATURE_LOCAL_DEPLOYMENT_ASSETS=true
--volume "{{ ORCHESTRATION_TOOLING_INSTALL_MANIFESTS_DIRECTORY }}:/manifests"
--env EXPERIMENTAL_FEATURE_DEPLOY_MANIFEST=true
--volume "{{ KUBECONFIG }}:/config/kubeconfig"
--volume "{{ DEPLOY_DIR }}:/src"
--volume "{{ DEPLOY_DIR }}:/deploy_dir"
"{{ V4_CFG_CR_HOST }}/{{ ORCHESTRATION_IMAGE }}"
deploy
deploy manifest
--namespace {{ NAMESPACE }}
--user-content /src
--local-deployment-assets
--manifest /deploy_dir/site.yaml
--deployment-dir /deploy_dir/sas-bases
when:
- deployment_tooling == "ansible"
- V4_CFG_BELOW_THE_LINE

- name: Deploy - Uninstall postgresclusters
environment:
Expand All @@ -133,14 +67,27 @@
- uninstall

- name: Deploy - Remove Viya
kubernetes.core.k8s:
state: absent
src: "{{ ORCHESTRATION_TOOLING_UNINSTALL_MANIFEST }}"
wait: true
wait_timeout: 600
namespace: "{{ NAMESPACE }}"
kubeconfig: "{{ KUBECONFIG }}"
ignore_errors: true
block:
- name: Deploy - Remove Viya - Deployment Operator
kubernetes.core.k8s:
state: absent
src: "{{ ORCHESTRATION_TOOLING_UNINSTALL_MANIFEST }}"
wait: true
wait_timeout: 600
namespace: "{{ NAMESPACE }}"
kubeconfig: "{{ KUBECONFIG }}"
ignore_errors: true
when:
- V4_DEPLOYMENT_OPERATOR_ENABLED
- name: Deploy - Remove Viya - sas-orchestration
kubernetes.core.k8s:
state: absent
src: "{{ DEPLOY_DIR }}/site.yaml"
namespace: "{{ NAMESPACE }}"
kubeconfig: "{{ KUBECONFIG }}"
ignore_errors: true
when:
- not V4_DEPLOYMENT_OPERATOR_ENABLED
tags:
- uninstall

Expand Down
13 changes: 13 additions & 0 deletions roles/vdm/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,19 @@

- name: Include SASDeployment Custom Resource
include_tasks: sasdeployment_custom_resource.yaml
when:
- V4_DEPLOYMENT_OPERATOR_ENABLED
tags:
- install
- uninstall
- update
- multi-tenancy

# Only applicable for sas-orchestration based deployments
- name: Include SAS Viya Kubernetes Manifest
include_tasks: sas_viya_kubernetes_manifest.yaml
when:
- not V4_DEPLOYMENT_OPERATOR_ENABLED
tags:
- install
- uninstall
Expand Down
59 changes: 59 additions & 0 deletions roles/vdm/tasks/sas_viya_kubernetes_manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright © 2020-2023, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

# The site.yaml SAS Viya Kubernetes manifest will only be generated if you set
# the V4_DEPLOYMENT_OPERATOR_ENABLED flag to false so that the sas-orchestration deploy command
# is being used to orchestrate the deployment.
---

- name: Create SAS Viya namespace
kubernetes.core.k8s:
api_version: v1
kind: Namespace
name: "{{ NAMESPACE }}"
wait: true
kubeconfig: "{{ KUBECONFIG }}"
tags:
- install
- update

- name: SAS Viya Kubernetes Manifest - clean up site.yaml
file:
state: absent
path: "{{ DEPLOY_DIR }}/site.yaml"
tags:
- install
- uninstall
- update
- cas-onboard
- offboard

- name: SAS Viya Kubernetes Manifest - generate site.yaml
tags:
- install
- uninstall
- update
- cas-onboard
- offboard
block:
- name: SAS Viya Kubernetes Manifest - generate site.yaml - Ansible
ansible.builtin.shell: >
docker run --rm
--user="{{ UID_GID }}"
--name "orchestration_{{ lookup('password', '/dev/null chars=ascii_lowercase length=8') }}"
--volume "{{ DEPLOY_DIR }}:/data"
--entrypoint kustomize
"{{ V4_CFG_CR_HOST }}/{{ ORCHESTRATION_IMAGE }}"
build /data/ -o /data/site.yaml
when:
- deployment_tooling == "ansible"
- name: SAS Viya Kubernetes Manifest - generate site.yaml - Docker
environment:
PATH: "{{ ORCHESTRATION_TOOLING_PATH }}"
command:
cmd: |
kustomize build {{ DEPLOY_DIR }}/ -o {{ DEPLOY_DIR }}/site.yaml
args:
chdir: "{{ ORCHESTRATION_TOOLING_DIRECTORY }}"
when:
- deployment_tooling == "docker"
71 changes: 0 additions & 71 deletions roles/vdm/tasks/sasdeployment_custom_resource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,30 +134,6 @@
dest: "{{ ORCHESTRATION_TOOLING_INSTALL_MANIFEST }}"
mode: "0660"

- name: sasdeployment custom resource - Write SAS Viya deployment manifests into orchestration tooling directory # noqa: name[casing]
when:
- not V4_DEPLOYMENT_OPERATOR_ENABLED
tags:
- install
- update
- cas-onboard
- offboard
block:
- name: sasdeployment custom resource - Create manifests directory in orchestration tooling directory # noqa: name[casing]
file:
path: "{{ ORCHESTRATION_TOOLING_INSTALL_MANIFESTS_DIRECTORY }}"
state: directory
mode: "0700"
- name: sasdeployment custom resource - Split SAS Viya deployment manifest into orchestration directory # noqa: name[casing]
command:
chdir: "{{ ORCHESTRATION_TOOLING_INSTALL_MANIFESTS_DIRECTORY }}"
cmd: |
csplit "{{ ORCHESTRATION_TOOLING_INSTALL_MANIFEST }}"
--prefix='{{ NAMESPACE }}-sasdeployment.'
--suffix-format='%03d.yaml'
--elide-empty-files
'/^----*$/' '{*}'

- name: sasdeployment custom resource - Create SAS Viya namespace # noqa: name[casing]
kubernetes.core.k8s:
api_version: v1
Expand Down Expand Up @@ -241,50 +217,3 @@
content: "{{ sasdeployment.stdout }}"
dest: "{{ ORCHESTRATION_TOOLING_UNINSTALL_MANIFEST }}"
mode: "0660"

- name: sasdeployment custom resource - Create SAS Viya uninstall manifest - Docker # noqa: name[casing]
when:
- not V4_DEPLOYMENT_OPERATOR_ENABLED
- deployment_tooling == "docker"
tags:
- uninstall
block:
- name: sasdeployment custom resource - Generate SAS Viya uninstall manifest # noqa: name[casing]
environment:
PATH: "{{ ORCHESTRATION_TOOLING_PATH }}"
WORK_DIRECTORY: "{{ ORCHESTRATION_TOOLING_DIRECTORY }}/work"
command:
cmd: |
kustomize build {{ DEPLOY_DIR }}
args:
chdir: "{{ ORCHESTRATION_TOOLING_DIRECTORY }}"
register: uninstall
- name: sasdeployment custom resource - Write SAS Viya uninstall manifest # noqa: name[casing]
copy:
content: "{{ uninstall.stdout }}"
dest: "{{ ORCHESTRATION_TOOLING_UNINSTALL_MANIFEST }}"
mode: "0660"

- name: sasdeployment custom resource - Create SAS Viya uninstall manifest - Ansible # noqa: name[casing]
when:
- not V4_DEPLOYMENT_OPERATOR_ENABLED
- deployment_tooling == "ansible"
tags:
- uninstall
block:
- name: sasdeployment custom resource - Generate SAS Viya uninstall manifest # noqa: name[casing]
ansible.builtin.shell: >
docker run --rm
--user="{{ UID_GID }}"
--name "orchestration_{{ lookup('password', '/dev/null chars=ascii_lowercase length=8') }}"
--volume "{{ DEPLOY_DIR }}:/data"
--volume "{{ ORCHESTRATION_TOOLING_DIRECTORY }}/work:/work"
--entrypoint kustomize
"{{ V4_CFG_CR_HOST }}/{{ ORCHESTRATION_IMAGE }}"
build /data
register: uninstall
- name: sasdeployment custom resource - Write SAS Viya uninstall manifest # noqa: name[casing]
copy:
content: "{{ uninstall.stdout }}"
dest: "{{ ORCHESTRATION_TOOLING_UNINSTALL_MANIFEST }}"
mode: "0660"
Loading