Immutable infrastructure 介紹與實做:以 kolla 為例

38

Click here to load reader

Transcript of Immutable infrastructure 介紹與實做:以 kolla 為例

Page 1: Immutable infrastructure 介紹與實做:以 kolla 為例

Immutable Infrastructure

Kuo-tung Kao

Page 2: Immutable infrastructure 介紹與實做:以 kolla 為例

簡介任職於 inwinstack過去的迎廣科技雲端應用研發中心OpenStack contributorkjellytw at gmail dot comhttp://www.blackwhite.tw/

Page 3: Immutable infrastructure 介紹與實做:以 kolla 為例

大綱Immutable infrastructure 介紹為什麼會有 immutable infrastructure?

immutable infrastructure 是什麼immutable infrastructure 的缺點

OpenStack Kolla 如何實現 Iimmutable infrastructure名詞解釋: OpenStack, Docker, Ansible,

OpenStack KollaOpenStack Kolla 實做

Page 4: Immutable infrastructure 介紹與實做:以 kolla 為例

為什麼會有 immutable infrastructure?

減輕 operator 的工作減少無紀錄的環境修改更容易升級 / 降級不容易升級失敗升級失敗也可以快速還原

Page 5: Immutable infrastructure 介紹與實做:以 kolla 為例

What’s the Iimmutable Iinfrastructure Don’t modify image manuallyCreate new image when something changes

Page 6: Immutable infrastructure 介紹與實做:以 kolla 為例

System Infrastructure is divided into "data" and "other".

"Other" are replaced at every deployment.

"Other" are modifed with version controll.

"Other" include “config”, “program”, “environment”.

Package “other” usingContainerHypervisor

Page 7: Immutable infrastructure 介紹與實做:以 kolla 為例

Running Container V1

volume

Running Container V2

volume

Stopped Container V1

Running Container V1

volume

Stopped Container V2

upgrade downgrade

Page 8: Immutable infrastructure 介紹與實做:以 kolla 為例

Immutable Infrastructure AdvantageAtomic deployments

Easy to upgradeEasy to downgradeFault recovery

Easy to track change

Page 9: Immutable infrastructure 介紹與實做:以 kolla 為例

Immutable Infrastructure DownsideCreate new image when something changes

Page 10: Immutable infrastructure 介紹與實做:以 kolla 為例

OpenStackOpen source software for creating private and public clouds.

OpenStack software controls large pools of compute, storage, and networking resources throughout a datacenter, managed through a dashboard or via the OpenStack API.

Page 11: Immutable infrastructure 介紹與實做:以 kolla 為例

DockerContainerLlighter, fast than hypervistorBuild envirenment from Dockerfile

Version ControllSupport named volume

Page 12: Immutable infrastructure 介紹與實做:以 kolla 為例

Dockerfile Demo

Page 13: Immutable infrastructure 介紹與實做:以 kolla 為例

Docker - run containerdocker run -e MYSQL_ROOT_PASSWORD=pass \ -d mysql:5.7.12

Page 14: Immutable infrastructure 介紹與實做:以 kolla 為例

AnsibleDeployment toolInterpretYamlJinja2Easy to write your own module in PythonAagentless

Page 15: Immutable infrastructure 介紹與實做:以 kolla 為例

Aansible Demo Sscript

Page 16: Immutable infrastructure 介紹與實做:以 kolla 為例

Aansible Demo Sscript

Page 17: Immutable infrastructure 介紹與實做:以 kolla 為例

OpenStack KollaDeploy OpenStack using Docker and Ansible

Support CephA little downtime when upgradingEasy to upgrade/downgradeRapid Deployment

Page 18: Immutable infrastructure 介紹與實做:以 kolla 為例

How to deploy OpenStack using Kollatools/build.py -t binary -b centostox -e genconfigsudo cp -rf etc/kolla /etc#modify /etc/kolla/globals.yamltools/generate_passwords.pytools/kolla-ansible pull #optionaltools/kolla-ansible deploy

Page 19: Immutable infrastructure 介紹與實做:以 kolla 為例

Kolla Code Structuredocker:

build imageansible:

generate openstack configrun container

Page 20: Immutable infrastructure 介紹與實做:以 kolla 為例

1.Encode the configuration into the build of the container

2.Encode the configuration into environment

3.Create the configuration file that the OpenStack service runs against outside the container

4.Encode the configuration file generated by the deployment tool into a JSON blob which sets the environment or configuration files appropriately.

Page 21: Immutable infrastructure 介紹與實做:以 kolla 為例

Kolla Code Structure

Page 22: Immutable infrastructure 介紹與實做:以 kolla 為例

Kolla - dockerfile, base

Run the same command in every container

Page 23: Immutable infrastructure 介紹與實做:以 kolla 為例

Kolla - docker, base

the file is generated by kolla_set_configs.

Page 24: Immutable infrastructure 介紹與實做:以 kolla 為例

Kolla - dockerfile, heat-api

Page 25: Immutable infrastructure 介紹與實做:以 kolla 為例

Create database schema when KOLLA_BOOTSTRAP is set

Page 26: Immutable infrastructure 介紹與實做:以 kolla 為例

Kolla - ansible, deploy, deploy.yaml

Page 27: Immutable infrastructure 介紹與實做:以 kolla 為例

Kolla - ansible, deploy, bootstrap.yaml

Create mysql databae using Ansible

Page 28: Immutable infrastructure 介紹與實做:以 kolla 為例

Kolla - ansible, deploy, bootstrap_service.yaml

Set env var, KOLLA_BOOTSTRAP

Page 29: Immutable infrastructure 介紹與實做:以 kolla 為例

Kolla - ansible, deploy, start.yaml

Page 30: Immutable infrastructure 介紹與實做:以 kolla 為例

Kolla - ansible, deploy, heat-api.json.j2

Page 31: Immutable infrastructure 介紹與實做:以 kolla 為例

Kolla - ansible, upgrade, bootstrap_service.yaml

Page 32: Immutable infrastructure 介紹與實做:以 kolla 為例

結論Immutable infrastructure 讓佈署更容易容易升級 / 降級當升級失敗時,能夠快速還原Kolla 和其他佈署方法相比,擁有快速佈署、快速升級降級的優點

Page 33: Immutable infrastructure 介紹與實做:以 kolla 為例

參考資料https://sdake.io/2015/11/11/the-tldr-on-immutable-infrastructure/

Page 34: Immutable infrastructure 介紹與實做:以 kolla 為例

Q&A

Page 35: Immutable infrastructure 介紹與實做:以 kolla 為例

Question用 Kolla 佈 OpenStack, 所謂 Downtime 很小是因為在建新的 image, 舊的系統仍正在service, total upgrading 時間仍然一樣還試 ?

Page 36: Immutable infrastructure 介紹與實做:以 kolla 為例

Answer在升級時,你可以事先將 image 建置好。等所有 image 都建置好後,再進行升級動作。在還沒執行 Ansible 腳本前,舊的系統依舊正常運作,不會有任何影響升級系統時,安裝套件很花時間。而 kolla 將這時間轉嫁到 build image ,而 build image 不會影響原本系統。這就是 kolla 可以快速升級、快速佈署的原因

Page 37: Immutable infrastructure 介紹與實做:以 kolla 為例

Question用 Kolla 佈 OpenStack, 適合用在企業的部屬嗎 ?

Page 38: Immutable infrastructure 介紹與實做:以 kolla 為例

Answer目前能做的客製化部分不夠多,所以不一定滿足不同的企業環境需要。不過如果你能夠修改 ansible 腳本,那麼有助於你突破一些限制 ( cinder multi backend 等 )未來 kolla 會支援 kubernetes 。或許可以等到 kolla 支援 kubernetes 在導入企業。 OpenStack 跑在 kubernetes 將會更強大