云原生
Posted 朱清云的技术博客
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了云原生相关的知识,希望对你有一定的参考价值。
我们经常在各种场合听到云原生, 翻译成英语就是Cloud Native; 网上搜索了一把,感觉每个人的理解都不一样;
有的文章说,云原生就是利用云的弹性,而且应用必须部署在云端;有的说,只要用了K8S计算云原生;有的说,把单体应用拆解成微服务应用,并部署到云端就是云原生。。。。。
1.什么是云原生
那到底什么才是云原生,追踪溯源,云原生(CloudNative)的概念首次由Pivotal公司的Matt Stine于2013年提出。Matt Stine在《迁移到云原生架构》(Migrating to Cloud-Native Application Architectures)一书中定义了符合云原生架构的几个特征:12因素(Twelve-Factor Applications)、微服务、自敏捷架构、基于API协作、扛脆弱性;下面就是其著名的12因素
- Codebase
Each deployable app is tracked as one codebase tracked in revi‐
sion control. It may have many deployed instances across multi‐
ple environments.
- Dependencies
An app explicitly declares and isolates dependencies via appro‐
priate tooling (e.g., Maven, Bundler, NPM) rather than depend‐
ing on implicitly realized dependencies in its deployment
environment.
- Config
Configuration, or anything that is likely to differ between
deployment environments (e.g., development, staging, produc‐
tion) is injected via operating system-level environment vari‐
ables.
- Backing services
Backing services, such as databases or message brokers, are
treated as attached resources and consumed identically across
all environments.
- Build, release, run
The stages of building a deployable app artifact, combining that
artifact with configuration, and starting one or more processes
from that artifact/configuration combination, are strictly sepa‐
rated.
- Processes
The app executes as one or more stateless processes (e.g., mas‐
ter/workers) that share nothing. Any necessary state is external‐
ized to backing services (cache, object store, etc.).
- Port binding
The app is self-contained and exports any/all services via port
binding (including HTTP).
- Concurrency
Concurrency is usually accomplished by scaling out app pro‐
cesses horizontally (though processes may also multiplex work
via internally managed threads if desired).
- Disposability
Robustness is maximized via processes that start up quickly and
shut down gracefully. These aspects allow for rapid elastic scal‐
ing, deployment of changes, and recovery from crashes.
- Dev/prod parity
Continuous delivery and deployment are enabled by keeping
development, staging, and production environments as similar
as possible.
- Logs
Rather than managing logfiles, treat logs as event streams,
allowing the execution environment to collect, aggregate, index,
and analyze the events via centralized services.
- Admin processes
Administrative or managements tasks, such as database migra‐
tions, are executed as one-off processes in environments identi‐
cal to the app’s long-running processes
到了2017年,Matt Stine在接受InfoQ采访时又改了口风,将云原生架构归纳为模块化、可观察、可部署、可测试、可替换、可处理6特质;而Pivotal最新官网对云原生概括为4个要点:DevOps+持续交付+微服务+容器。因为企业需要一个用于构建和运行云原生应用和服务的平台,来自动执行并集成 DevOps、持续交付、微服务和容器。正如VMware的联合创始人 Joe Beda 如下所说,
Cloud native is structuring teams, culture, and technology to utilize automation and architectures to manage complexity and unlock velocity.
- DevOps
- 持续交付
- 微服务
- 容器
上面四个具体概念就不一一展开,网上资料很多。
2.为什么云原生
云原生应用专为云模型而开发。小的专用功能团队快速将这些应用构建和部署到可提供轻松的横向扩展和硬件解耦的平台,为企业提供更高的敏捷性、弹性和云间的可移植性。
- 云是一种竞争优势
云意味着按需,弹性,大大降低的中小型企业的成本;同时也意味着高可用性,比如搭建一个2地3中心就是非常容易的事情;这要是搁在传统的数据中心,成本和工期是巨大的。
-
灵活性
因为应用是基于微服务的,也是基于Docker Image去部署的,所以应用程序在不同的云厂商迁移,或者从企业内部迁移到云端,反过来也一样,都是非常灵活和容易的。 -
让开发人员以最好的状态工作
成熟的DevOps不仅仅可以让公司的文化更为敏捷,而且也提供了一键编译,构建,部署,测试的全流程自动化。
采用云原生应用的团队可为开发人员省去为了在各种云基础架构间运行和扩展而编写代码所产生的开销,让他们专注于编写能够交付客户价值的代码。标准化开发人员体系上的 12 因素应用需要一套标准的服务,从而提供标准的开发人员“合同”,确保其应用充分利用底层的云原生平台。
- 协调运营和业务
通过实现自动化 IT 运营,企业可以转变为一个重点明确的精益团队,与推动业务优先事项保持一致。由于员工专注于流程改进,而不是日常的普通管理任务,他们可以消除由于人为错误导致的故障风险。通过在体系的所有层面进行自动化的实时修补和升级,他们可以消除停机时间,并且不再需要具有“传承”专业知识的运营专家。
说白了,上面的四点就是DevOps,持续交付,微服务,容器的优点,通过上面的四大手段,从而实现传统企业应用无法或者很难实现的下面9大优势:
- 云原生应用
- 可预测
- 操作系统抽象化
- 合适的容量
- 开发运维无缝协作
- 持续交付
- 独立
- 自动化可扩展性
- 快速恢复
参考文献
https://tanzu.vmware.com/cn/cloud-native
http://www.java1234.com/a/javabook/andriod/2018/0317/10665.html
以上是关于云原生的主要内容,如果未能解决你的问题,请参考以下文章