mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
60008a5103
@ -1,8 +1,8 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-11617-1.html)
|
||||
[#]: subject: (Bauh – Manage Snaps, Flatpaks and AppImages from One Interface)
|
||||
[#]: via: (https://itsfoss.com/bauh-package-manager/)
|
||||
[#]: author: (John Paul https://itsfoss.com/author/john/)
|
||||
@ -10,21 +10,29 @@
|
||||
bauh:在一个界面中管理 Snap、Flatpak 和 AppImage
|
||||
======
|
||||
|
||||
[Snap][1]、[Flatpak][2] 和 [AppImage][3] 等通用软件包的最大问题之一就是管理它们。大多数内置的软件包管理器不能全部支持这些新格式。
|
||||
![](https://img.linux.net.cn/data/attachment/album/201911/27/092926pzzdtytda80yaany.jpg)
|
||||
|
||||
幸运的是,我偶然发现了一个支持几种通用包格式的应用程序。
|
||||
[Snap][1]、[Flatpak][2] 和 [AppImage][3] 等通用软件包的最大问题之一就是管理它们。大多数内置的软件包管理器都不能全部支持这些新格式。
|
||||
|
||||
### Bauh:多包装需求的管理器
|
||||
幸运的是,我偶然发现了一个支持这几种通用包格式的应用程序。
|
||||
|
||||
[bauh][4](LCTT:给该软件建议一个中文名:“包豪”)最初名为 fpakman,旨在处理 Flatpak、Snap、[AppImage][5] 和 [AUR][6] 软件包。创建者 [vinifmor][7] 在 2019 年 6 月启动了该项目,[意图][8]“为 Manjaro 用户提供管理 Flatpak 的图形界面”。此后,他扩展了该应用程序,以添加对基于 Debian 的系统的支持。
|
||||
### bauh:多包装需求的管理器
|
||||
|
||||
[bauh][4](LCTT:我给该软件建议一个中文名:“包豪”)最初名为 fpakman,旨在处理 Flatpak、Snap、[AppImage][5] 和 [AUR][6] 软件包。创建者 [vinifmor][7] 在 2019 年 6 月启动了该项目,[意图][8]“为 Manjaro 用户提供管理 Flatpak 的图形界面”。此后,他扩展了该应用程序,以添加对基于 Debian 的系统的支持。
|
||||
|
||||
![Bauh About][9]
|
||||
|
||||
首次打开 bauh 时,它将扫描已安装的应用程序并检查更新。如果有任何需要更新的内容,它们将列在前面并居中。更新所有软件包后,你将看到已安装的软件包列表。你可以取消选择需要更新的软件包,以防止其被更新。你也可以选择安装该应用程序的早期版本。
|
||||
首次打开 bauh 时,它将扫描已安装的应用程序并检查更新。如果有任何需要更新的内容,它们将列在前面并居中。更新所有软件包后,你将看到已安装的软件包列表。你可以取消选择不需要更新的软件包,以防止其被更新。你也可以选择安装该应用程序的早期版本。
|
||||
|
||||
![With Bauh you can manage various types of packages from one application][10]
|
||||
|
||||
你也可以搜索应用程序。bauh 提供了有关已安装和已搜索软件包的详细信息。如果你对一种(或多种)打包类型不感兴趣,则可以在设置中取消选择它们。
|
||||
你也可以搜索应用程序。bauh 提供了有关已安装和已搜索软件包的详细信息。如果你对一种(或多种)软件包类型不感兴趣,则可以在设置中取消选择它们。
|
||||
|
||||
![Bauh Search][22]
|
||||
|
||||
![Bauh Package Info][13]
|
||||
|
||||
![Bauh Updating][19]
|
||||
|
||||
### 在你的 Linux 发行版上安装 bauh
|
||||
|
||||
@ -38,8 +46,6 @@ bauh:在一个界面中管理 Snap、Flatpak 和 AppImage
|
||||
sudo pacman -S bauh
|
||||
```
|
||||
|
||||
![Bauh Package Info][13]
|
||||
|
||||
#### 基于 Debian/Ubuntu 的发行版
|
||||
|
||||
如果你拥有基于 Debian 或 Ubuntu 的 Linux 发行版,则可以使用 `pip` 安装 bauh。首先,请确保[在 Ubuntu 上安装了 pip][14]。
|
||||
@ -76,8 +82,6 @@ env/bin/pip install .
|
||||
env/bin/bauh
|
||||
```
|
||||
|
||||
![Bauh Updating][19]
|
||||
|
||||
一旦完成了 bauh 的安装,就可以通过更改环境设置和参数来对其进行[微调][20]。
|
||||
|
||||
### bauh 的未来之路
|
||||
@ -88,8 +92,6 @@ bauh 在短短的几个月中增长了很多。它有计划继续增长。当前
|
||||
* 每种打包技术一个单独模块
|
||||
* 内存和性能改进
|
||||
* 改善用户体验
|
||||
|
||||
![Bauh Search][22]
|
||||
|
||||
### 结语
|
||||
|
@ -52,7 +52,7 @@ SoC 制造商添加了支持 CPU 和其他芯片的代码后,便会将该内
|
||||
|
||||
到目前为止,这只是一个草案。谷歌有很大的可能会开始进行该项目,除非他们意识到这将需要多少工作后才会放弃。看看谷歌[已经放弃][7]了多少个项目!
|
||||
|
||||
[Android Police][4] 指出谷歌正在开发其 [Fuchsia 操作系统][8],这似乎是为了有一天取代谷歌。
|
||||
[Android Police][4] 指出谷歌正在开发其 [Fuchsia 操作系统][8],这似乎是为了有一天取代安卓。
|
||||
|
||||
那么,问题是谷歌会尝试完成那些艰巨的任务,使安卓以主线 Linux 内核运行,还是完成他们统一的安卓替代产品的工作?只有时间可以回答。
|
||||
|
||||
|
@ -0,0 +1,61 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Fail-free Kubernetes, significant events, and more industry trends)
|
||||
[#]: via: (https://opensource.com/article/19/11/fail-free-kubernetes-and-more-trends)
|
||||
[#]: author: (Tim Hildred https://opensource.com/users/thildred)
|
||||
|
||||
Fail-free Kubernetes, significant events, and more industry trends
|
||||
======
|
||||
A weekly look at open source community, market, and industry trends.
|
||||
![Person standing in front of a giant computer screen with numbers, data][1]
|
||||
|
||||
As part of my role as a senior product marketing manager at an enterprise software company with an open source development model, I publish a regular update about open source community, market, and industry trends for product marketers, managers, and other influencers. Here are five of my and their favorite articles from that update.
|
||||
|
||||
## [Why teams fail with Kubernetes—and what to do about it][2]
|
||||
|
||||
> Fail to address the questions "Who is responsible for _x_?" and "Who is affected by _y_?" and you'll put all your efforts at risk. For example, replace "_x_" above with "deciding on namespaces versus clusters for service and environment isolation" or "upgrading all clusters to a new Kubernetes version," and you start to see why you need to clarify the boundaries of responsibility and their impacts.
|
||||
|
||||
**The impact**: Wouldn't it be nice if operators and role-based access control could make the messiness of human interaction go away? Why can't auto-scaling just mean auto-scaling? Tough luck! You're going to have to figure out the people side of it too!
|
||||
|
||||
## [The New Stack Context: The past, present, and future of Kubernetes][3]
|
||||
|
||||
> What have been some of the most significant events in the Kubernetes and cloud native community over the past year? A lot of work has been done in slimming and stabilizing the core. Operators were a growing trend over the past year—operators are mechanisms to expand the number of things you can build on top of Kubernetes. We are seeing Kubernetes expand into new workloads as well.
|
||||
|
||||
**The impact**: In some way, Kubernetes is an ongoing effort in re-building the airplane mid-flight. The good news is that we're getting better at doing that, and the future holds ubiquity, according to this podcast.
|
||||
|
||||
## [Q&A: Fidelity invests in cloud-native, open source projects to step up innovation][4]
|
||||
|
||||
> “We are seeing that Kubernetes, CNCF, and cloud-native technology are the key players for us when we go multicloud and hybrid-cloud model,” said [Amr Abdelhalem][5] (pictured), head of cloud platforms at Fidelity Investments. “That’s why we are here. We are here actually in Kubernetes and KubeCon for that reason. That’s where we see this abstract layer that guarantees you the portability for moving your application from one cloud provider to another.”
|
||||
|
||||
**The impact**: Think about this: Fidelity is a member of the CNCF. What does that mean about the distance between the creator and consumer of open source software? It's exciting because it exemplifies the participatory ideals of open source; its a new challenge for the ecosystem because participants are starting to represent industry verticals that might not have much overlap whose needs need reconciliation. Fun times!
|
||||
|
||||
## [The future of hybrid cloud is bright as 73% of enterprises moving apps back on Prem][6]
|
||||
|
||||
> This year’s report illustrated that creating and executing a cloud strategy has become a multidimensional challenge. At one time, a primary value proposition associated with the public cloud was substantial upfront capex savings. Now, enterprises have discovered that there are other considerations when selecting the best cloud for the business as well, and that one size cloud strategy doesn’t fit all use cases. For example, while applications with unpredictable usage may be best suited to the public clouds offering elastic IT resources, workloads with more predictable characteristics can often run on-premises at a lower cost than public cloud. Savings are also dependent on businesses’ ability to match each application to the appropriate cloud service and pricing tier, and to remain diligent about regularly reviewing service plans and fees, which change frequently.
|
||||
|
||||
**The impact**: The short version is that cost is not the only, or even the most important factor, in choosing where to run a workload. More and more often it is the nature of the workload itself.
|
||||
|
||||
_I hope you enjoyed this list of what stood out to me from last week and come back next Monday for more open source community, market, and industry trends._
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/11/fail-free-kubernetes-and-more-trends
|
||||
|
||||
作者:[Tim Hildred][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/thildred
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data)
|
||||
[2]: https://techbeacon.com/enterprise-it/why-teams-fail-kubernetes-what-do-about-it
|
||||
[3]: https://thenewstack.io/the-new-stack-context-the-past-present-and-future-of-kubernetes/
|
||||
[4]: https://siliconangle.com/2019/11/21/qa-fidelity-invests-cloud-native-open-source-projects-step-innovation-kubecon/
|
||||
[5]: https://www.linkedin.com/in/amrhalem/
|
||||
[6]: https://www.dqindia.com/the-future-of-hybrid-cloud-is-bright-as-73-of-enterprises-moving-apps-back-on-prem/
|
@ -0,0 +1,105 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Zorin OS Responds to the Privacy Concerns)
|
||||
[#]: via: (https://itsfoss.com/zorin-os-privacy-concerns/)
|
||||
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
|
||||
|
||||
Zorin OS Responds to the Privacy Concerns
|
||||
======
|
||||
|
||||
_**There were some privacy concerns around ‘data collection’ in Zorin OS. It’s FOSS spoke to Zorin OS CEO and here is his response to the controversy.**_
|
||||
|
||||
After a few days of [Zorin OS 15 Lite][1] release, a Reddit thread surfaced which flagged a privacy concern regarding the Linux distribution.
|
||||
|
||||
The [Reddit thread][2] focuses on the [privacy policy][3] of Zorin OS and warns users that Zorin OS is sending anonymous pings every 60 minutes without users’ consent, which is potentially a privacy issue.
|
||||
|
||||
![][4]
|
||||
|
||||
The policy in question can be quoted here as:
|
||||
|
||||
> _**Anonymous pings**: When using Zorin OS, your computer may occasionally send us a ping which includes an anonymous unique identifier for your computer. We use this information to count the number of active users of Zorin OS. The unique identifier does not identify you unless you (or someone acting on your behalf) discloses it separately. You may choose to disable these pings by uninstalling the “Zorin-os-census” package from your computer_
|
||||
|
||||
Now, there’s a lot of [discussions][5] surrounding the concern. There’s also a [YouTube video][6] talking about it.
|
||||
|
||||
In a nutshell, it’s a mess. Some insist that they collect our IP addresses and some users complain that they should ask about it while installing Zorin OS.
|
||||
|
||||
While I agree that they could add an opt-out option in the installation process – so I reached out to **Artyom Zorin** (_CEO, Zorin Group_) to clarify the situation.
|
||||
|
||||
### Zorin’s Clarification On What They Collect With Every Anonymous Ping
|
||||
|
||||
When I asked for an elaborate explanation of what the “**anonymous unique identifier**” includes, Artyom mentioned – “_It appears that there are some inaccuracies and misconceptions about the census in the comments sections_“.
|
||||
|
||||
To continue the explanation about the unique identifier, he assured that **their servers do not log IP addresses** when a ping arrives.
|
||||
|
||||
The zorin-os-census script **simply counts the number of unique computers using Zorin OS** and no personal data is being collected along with it.
|
||||
|
||||
Artyom explained in detail:
|
||||
|
||||
> The anonymous identifier is a series of letters and numbers which is randomly generated (not based on any external data) and only used for the Zorin OS Census. Its single purpose is to make sure that the computer isn’t double-counted when a ping is sent from a computer to the server. On a fully-installed Zorin OS system, the anonymous identifier can be found in /var/lib/zorin-os-census/uuid and should look like this:_68f2d95b-f51f-4a5d-9b48-a99c28691b89_
|
||||
> *
|
||||
> *We would like to clarify that no personal or personally-identifiable data is being collected by us and the server does not log IP addresses when pings arrive. The zorin-os-census script is only used to count the number of computers and users running Zorin OS after installation. Even I wouldn’t be able to tell which computer is my own from looking at the server-side database. I have attached a screenshot of a snippet of the database table displaying the information we store.
|
||||
|
||||
He also stressed his ‘commitment on privacy’:
|
||||
|
||||
> Privacy is an essential human right. It’s a core tenet of our mission to give you back control of your technology, and not the other way around. We make privacy a priority with every decision we make, and we’re committed to protecting it in every level of the software we build.
|
||||
|
||||
As you can observe in the response above, he shared a screenshot of how their database of unique identifiers looks like:
|
||||
|
||||
![][7]
|
||||
|
||||
If you’re still curious, you can also check out the [source code][8] for the zorin-os-census script.
|
||||
|
||||
### Can We Opt-Out Of It?
|
||||
|
||||
While the data collected may be ‘harmless’, it is important to give the option to the user whether or not they want Zorin OS to collect the data, right?
|
||||
|
||||
So, when I inquired about the same, he mentioned that i**t was already something planned for Zorin OS 15 Lite release**.
|
||||
|
||||
However, they did not want to rush to add it before properly testing it. Hence, they decided to keep it for the upcoming release (**Zorin OS 15.1**) which is planned to arrive in **early-to-mid December this year.**
|
||||
|
||||
> We have in fact been working on implementing an opt-out option for this into the Zorin OS installer (Ubiquity). To ensure the stability and accessibility of this new functionality we’re adding to Ubiquity, we have scheduled a period of time to translate the text strings and rigorously test the software (in order to avoid regressions), as the installer is a critical component of the operating system. Unfortunately, the testing period for the opt-out option didn’t complete before our planned release of Zorin OS 15 Lite, and we, therefore, decided not to risk adding it before we could guarantee its stability. However, we are on track to include the opt-out option in the upcoming Zorin OS 15.1 release, which we plan to release in early-to-mid December.
|
||||
|
||||
### Will It Be Something Similar To What Ubuntu Does?
|
||||
|
||||
Ubuntu does let you opt-out from collecting information about your computer.
|
||||
|
||||
So, when I asked if Zorin OS will add something similar to that, he responded with some details about how Ubuntu collects data and how Zorin OS is different from that.
|
||||
|
||||
He mentioned the fact that Ubuntu comes pre-installed with a **popularity-contest** package that **occasionally sends data of what packages the user has installed** to the Ubuntu Developers.
|
||||
|
||||
And, further clarified that **Zorin OS does not include that**.
|
||||
|
||||
> While Ubuntu’s telemetry tool gives users the option to not send extensive information about the computers to the Ubuntu developers, selecting the “No” option still sends a ping to Ubuntu’s servers .
|
||||
>
|
||||
> From our research, it is not clear whether Ubuntu’s servers store logs of users’ IP addresses when they receive telemetry data. In addition, Zorin OS does not include the “popularity-contest” package that is pre-installed in Ubuntu. This package is designed to occasionally send a list of all packages a user has installed on their computer to the Ubuntu developers.
|
||||
|
||||
**In the end…**
|
||||
|
||||
While the concern regarding the anonymous pings may not seem to a privacy threat, an opt-out option should be presented to the user while installing Zorin OS. Let’s wait and watch if it should arrive in the upcoming Zorin OS 15.1 release.
|
||||
|
||||
What do you think about the privacy concern mentioned above? Let us know your thoughts in the comments down below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/zorin-os-privacy-concerns/
|
||||
|
||||
作者:[Ankush Das][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/ankush/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://itsfoss.com/zorin-os-lite/
|
||||
[2]: https://www.reddit.com/r/FreeAsInFreedom/comments/e0yhw4/beware_zorin_os_sends_anonymous_pings_every_60/
|
||||
[3]: https://zorinos.com/legal/privacy/
|
||||
[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/zorin-os-privacy-reddit.jpg?ssl=1
|
||||
[5]: https://www.reddit.com/r/linux/comments/e0zd5n/beware_zorin_os_sends_anonymous_pings_every_60/
|
||||
[6]: https://www.youtube.com/watch?v=bcgk9LvC36Y&feature=youtu.be&t=860
|
||||
[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/11/zorin-census-database.png?ssl=1
|
||||
[8]: https://launchpad.net/~zorinos/+archive/ubuntu/stable/+sourcepub/10183568/+listing-archive-extra
|
@ -0,0 +1,124 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (A framework for building products from open source projects)
|
||||
[#]: via: (https://opensource.com/article/19/11/products-open-source-projects)
|
||||
[#]: author: (Kevin Xu https://opensource.com/users/kevin-xu)
|
||||
|
||||
A framework for building products from open source projects
|
||||
======
|
||||
Here is a roadmap for turning a project into a commercial open source
|
||||
product.
|
||||
![An airplane.][1]
|
||||
|
||||
My first memory of playing with a computer was through an [MS-DOS][2] terminal on the x86 PC in my grandfather's pharmaceutical research lab in the early '90s—playing games stored on 3.5" floppy disks and doing touch-typing exercises. As technology improved, I spent an obscene amount of time taking my computer apart to add more RAM, a new graphics card, or a new fan, mostly so I could play cooler games. It was a fun, ongoing project, and I bonded with my father over it. It was also way cheaper than buying a new computer.
|
||||
|
||||
What's the point of this in the context of open source?
|
||||
|
||||
Well, even though I had no idea what "open source" was at the time, I was behaving like a typical developer does with open source projects today—spending my free time to piece together and build things I wanted, sometimes for a specific goal, sometimes to learn new things, sometimes as a way to connect with others.
|
||||
|
||||
But, over time, I stopped tinkering. For whatever reason, I decided that my time was becoming too "valuable" to retrofit my older computers. I started using a MacBook, and when my older MacBook wasn't functioning well, I paid a pretty penny for a new one with a better configuration instead of unscrewing the bottom to see if I could jam in a new RAM card.
|
||||
|
||||
My behavior became more like that of an enterprise buyer—saving time and trouble by spending money.
|
||||
|
||||
### An open source software project is not a product you sell
|
||||
|
||||
If your experience with technology resembles mine in any way, you know intuitively that the _projects_ we [DIY][3] are not the same as the _products_ we spend money buying.
|
||||
|
||||
This isn't a new observation in the open source community.
|
||||
|
||||
[Stephen Walli][4], an IT industry veteran and part of the [Open Container Initiative][5], has written [numerous detailed blog posts][6] on this topic. [Sarah Novotny][7], who led the Kubernetes community and was heavily involved in the Nginx and MySQL communities, [emphatically articulated][8] at the inaugural [Open Core Summit][9] that the open source project a company shepherds and the product that a company sells are two completely _different_ things.
|
||||
|
||||
Yet, project and product continue to be conflated by maintainers-turned-founders of commercial open source software (COSS) companies, especially (and ironically) when the open source project gets traction.
|
||||
|
||||
This mistake gets repeated, I believe, because it's hard to mentally conceptualize how and why a commercial product should be different when the open source project is already being used widely.
|
||||
|
||||
### What makes a COSS product different?
|
||||
|
||||
Two core elements differentiate a commercial product from its open source root: packaged experience and buyer-specific features.
|
||||
|
||||
#### Packaged experience
|
||||
|
||||
Packaging your project so that it has that out-of-the-box user experience isn't just about a polished user interface (UI) or hosting it on your server as SaaS (although that could be part of it). It's an expressed opinion of how you, the creator or maintainer of the project turned founder of the company, believe the technology should be used to solve your customer's business problem. That "opinion" is essentially the product experience the customer is paying for.
|
||||
|
||||
When you are running an open source community project, it's usually good to be _not_ opinionated and let your community organically flourish. When you are developing a product for customers, it's usually good to _be_ opinionated.
|
||||
|
||||
It's the retrofitted x86 PC versus the MacBook dynamic.
|
||||
|
||||
[Dave McJannet][10], CEO of Hashicorp, and [Peter Reinhardt][11], CEO of Segment, both cited packaging as a crucial step to get right in order to turn an open source project into a scalable commercial product.
|
||||
|
||||
#### Buyer-specific features
|
||||
|
||||
A well-packaged product must also have the features that are necessary for your targeted buyer to justify a purchase. What these features are depends on the profile of your buyer, but the possibilities are finite and manageable.
|
||||
|
||||
An enterprise buyer, say a Global 2000, will have a relatively consistent set of features that it must have to purchase a product. ([EnterpriseReady.io][12] is a great resource about what those features tend to be.)
|
||||
|
||||
A small- or medium-sized business buyer, say your local mom-and-pop bakery, that has less financial resources and people power and is more price-sensitive, will need different things to be convinced to buy.
|
||||
|
||||
A consumer service monetized via ads, where your buyers are the advertisers while your users are everyday people, will be different still.
|
||||
|
||||
One thing is for sure: your buyer is almost _never_ your open source community.
|
||||
|
||||
Know what your buyer requires for a purchase, and package that with your expert opinion on how to solve the buyer's problem; **that's what differentiates a product from a project.**
|
||||
|
||||
Sid Sijbrandij's articulation of GitLab's [buyer-based open core][13] model is a good example for enterprises.
|
||||
|
||||
Certainly, other elements can be added to further the differentiation. But a packaged experience with buyer-specific features is essential. Without one or the other, your prospective customers might as well just tinker on their own for free.
|
||||
|
||||
### One metric that matters: Time-to-value
|
||||
|
||||
A perennially difficult thing in product development is measuring progress and establishing a data-driven framework to determine whether you are on the right path or not. I'm a fan of the One Metric That Matters (OMTM) mentality, elaborated in [_Lean Analytics_][14], where you focus on one single number (above everything else) for your current stage. This approach enforces focus and discipline among a sea of data you can gather and distract yourself with (oftentimes vanity metrics like download numbers or GitHub stars). The single metric can effectively rally your entire company around one tangible goal or mission—especially critical for an early-stage company. And the metric you focus on will be different at different stages.
|
||||
|
||||
So what's the right OMTM in the early days of product development?
|
||||
|
||||
I propose **time-to-value**
|
||||
|
||||
"Time" here is straightforward—the lower, the better.
|
||||
|
||||
"Value" needs a precise, rigorous definition that is technology- and problem-specific. Your distributed database is valuable because it can serve data with no downtime when servers fail. Your continuous integration tool is valuable because it enables application developers to push improvements faster without breaking the application. You get the idea.
|
||||
|
||||
How quickly can a customer see or feel the _one core piece of value_ that you measure and optimize for? Whatever is "a sufficiently short time" depends on the use case, but given the increasing consumerization of enterprise technology, any product's time-to-value that's more than 30 minutes is probably too long.
|
||||
|
||||
Finding and tightly defining that "value" is hard and iterative, but also table stakes if you are looking to build a product company around an open source project. Without a deep understanding of what that value is for your customer, there's probably not much of a company to build.
|
||||
|
||||
At the end of the day, as much fun as it was to "beef up" my x86 PC, I'm pretty satisfied with my MacBook and happy to pay the premium. So don't get too enamored with the joy of tinkering if your goal is actually to sell MacBook.
|
||||
|
||||
(P.S. The mental framework outlined here may not apply if you are building a consultancy or support-oriented company that services open source project users. For more expansive reading on different COSS business models, see _[_COSS business model progressions_][15]_ by Joseph Jacks.)
|
||||
|
||||
_Special thanks to Sarah Novotny for her feedback on this post's draft._
|
||||
|
||||
* * *
|
||||
|
||||
_This article was [previously published on COSS Media][16] and is edited and republished with permission._
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/11/products-open-source-projects
|
||||
|
||||
作者:[Kevin Xu][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/kevin-xu
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/206308main_image_976_946-710.jpg?itok=U6hh3EIO (An airplane.)
|
||||
[2]: https://en.wikipedia.org/wiki/MS-DOS
|
||||
[3]: https://en.wikipedia.org/wiki/Do_it_yourself
|
||||
[4]: https://stephesblog.blogs.com/about.html
|
||||
[5]: https://www.opencontainers.org/
|
||||
[6]: https://medium.com/@stephenrwalli
|
||||
[7]: https://sarahnovotny.com/about/
|
||||
[8]: https://www.linkedin.com/pulse/personal-reflection-open-core-summit-kevin-xu/
|
||||
[9]: https://opencoresummit.com/#speakers
|
||||
[10]: https://founderrealtalk.ggvc.com/2019/04/25/episode-23-hashicorp-ceo-dave-mcjannet-reveals-the-secrets-of-commercializing-open-source-selling-to-enterprises-and-building-successful-relationships-with-founders/
|
||||
[11]: https://www.youtube.com/watch?v=Q75V35unztw&feature=youtu.be
|
||||
[12]: https://www.enterpriseready.io/#
|
||||
[13]: https://www.youtube.com/watch?v=G6ZupYzr_Zg
|
||||
[14]: http://leananalyticsbook.com/
|
||||
[15]: https://coss.media/coss-business-model-progressions/
|
||||
[16]: https://coss.media/deriving-product-from-open-source/
|
@ -0,0 +1,88 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How cloud providers' performance differs)
|
||||
[#]: via: (https://www.networkworld.com/article/3455197/how-cloud-providers-performance-differs.html)
|
||||
[#]: author: (Zeus Kerravala https://www.networkworld.com/author/Zeus-Kerravala/)
|
||||
|
||||
How cloud providers' performance differs
|
||||
======
|
||||
The 2019 ThousandEyes Benchmark report shows that not all cloud providers are created equal across all regions
|
||||
Denis Isakov / Getty Images
|
||||
|
||||
Not all public cloud service providers are the same when it comes to network performance.
|
||||
|
||||
Each one’s connectivity approach varies, which causes geographical discrepancies in network performance and predictability. As businesses consider moving to the cloud, especially software-defined wide-area networks ([SD-WAN][1]) and [multi-cloud][2], it’s important to understand what each public cloud service provider brings to the table and how they compare.
|
||||
|
||||
[[Get regularly scheduled insights by signing up for Network World newsletters.]][3]
|
||||
|
||||
In 2018, ThousandEyes first conducted [a benchmark study assessing three major public cloud providers][4]: Amazon Web Services (AWS), Microsoft Azure (Azure), and Google Cloud Platform (GCP). The study gathered data on network performance and connectivity architecture to guide businesses in the planning stage.
|
||||
|
||||
[][5]
|
||||
|
||||
BrandPost Sponsored by HPE
|
||||
|
||||
[HPE Synergy For Dummies][5]
|
||||
|
||||
Here’s how IT can provide an anytime, anywhere, any workload infrastructure.
|
||||
|
||||
[This year’s study][6] offers a more comprehensive view of the competition, with two more providers added to the list: Alibaba Cloud and IBM Cloud. It compares 2018 and 2019 data to show changes that took place year-over-year and what triggered them.
|
||||
|
||||
ThousandEyes periodically collected bi-directional network performance metrics—such as latency, packet loss and jitter—from 98 user vantage points in global [data centers][7] across all five public cloud providers over a four-week period. Additionally, it looked at network performance from leading U.S. broadband internet service providers (ISPs), including AT&T, Verizon, Comcast, CenturyLink, Cox, and Charter.
|
||||
|
||||
The network management company then analyzed more than 320 million data points to create the benchmark. Here are the results.
|
||||
|
||||
### Inconsistencies among providers
|
||||
|
||||
In its initial study, ThousandEyes revealed that some cloud providers rely heavily on the public internet to carry user traffic while others don’t. In this year’s study, the cloud providers generally showed similar performance in bi-directional network latency.
|
||||
|
||||
However, ThousandEyes found architectural and connectivity differences have a big impact on how traffic travels between users and certain cloud hosting regions. AWS and Alibaba mostly rely on the internet to transport user traffic. Azure and GCP use their private backbone networks. IBM is different from the rest and takes a hybrid approach.
|
||||
|
||||
ThousandEyes tested the theory of whether AWS Global Accelerator out-performs the internet. AWS Global Accelerator launched in November 2018, offering users the option to utilize the AWS private backbone network for a fee instead of the default public internet. Although performance did improve in some regions around the world, there where other instances where the internet was faster and more reliable than AWS Global Accelerator.
|
||||
|
||||
Broadband ISPs that businesses use to connect to each cloud also showed inconsistencies, even in the mature U.S. market. After evaluating network performance from the six U.S. ISPs, sub-optimal routing results were recorded, with up to 10 times the expected network latency in some cases.
|
||||
|
||||
**Location, location, location**
|
||||
|
||||
Cloud providers commonly experience packet loss when crossing through China’s content-filtering firewall, even those from the region like Alibaba. The 2019 study closely examined the performance toll cloud providers pay in China, which has a notoriously challenging geography for online businesses. For those with customers in China, ThousandEyes recommends Hong Kong as a hosting region since Alibaba Cloud traffic experienced the least packet loss there, followed by Azure and IBM.
|
||||
|
||||
In other parts of the world, Latin America and Asia showed the highest performance variations for all cloud providers. For example, network latency was six times higher from Rio de Janeiro to GCP’s São Paulo hosting region because of a suboptimal reverse path, compared to other providers. But across North America and Western Europe, all five cloud providers demonstrated comparable, robust network performance.
|
||||
|
||||
The study’s results confirm that location is a major factor, therefore, user-to-hosting-region performance data should be considered when selecting a public cloud provider.
|
||||
|
||||
**Multi-cloud connectivity**
|
||||
|
||||
In 2018, ThousandEyes discovered extensive connectivity between the backbone networks of AWS, GCP, and Azure. An interesting finding in this year’s study shows multi-cloud connectivity was erratic when IBM and Alibaba Cloud were added to the list.
|
||||
|
||||
ThousandEyes found IBM and Alibaba Cloud don’t have fully established, direct connectivity with other providers. That’s because they typically use ISPs to connect their clouds to other providers. AWS, Azure, and GCP, on the other hand, peer directly with each other and don’t require third-party ISPs for multi-cloud communication.
|
||||
|
||||
With multi-cloud initiatives on the rise, network performance should be included as a metric in evaluating multi-cloud connectivity since it appears to be inconsistent across providers and geographical boundaries.
|
||||
|
||||
ThousandEyes’ comprehensive performance benchmark can serve as a guide for businesses deciding which public cloud provider best meets their needs. But to err on the side of caution, businesses selecting public cloud connectivity should consider the unpredictable nature of the internet, how it affects performance, creates risk, and increases operational complexity. Businesses should address those challenges by gathering their own network intelligence on a case-by-case basis. Only then they will benefit fully from what cloud providers have to offer.
|
||||
|
||||
Join the Network World communities on [Facebook][8] and [LinkedIn][9] to comment on topics that are top of mind.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3455197/how-cloud-providers-performance-differs.html
|
||||
|
||||
作者:[Zeus Kerravala][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.networkworld.com/author/Zeus-Kerravala/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.networkworld.com/article/3031279/sd-wan-what-it-is-and-why-you-ll-use-it-one-day.html
|
||||
[2]: https://www.networkworld.com/article/3429258/real-world-tools-for-multi-cloud-management.html
|
||||
[3]: https://www.networkworld.com/newsletters/signup.html
|
||||
[4]: https://www.networkworld.com/article/3319776/the-network-matters-for-public-cloud-performance.html
|
||||
[5]: https://www.networkworld.com/article/3399618/hpe-synergy-for-dummies.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE19718&utm_content=sidebar (HPE Synergy For Dummies)
|
||||
[6]: https://www.thousandeyes.com/press-releases/second-annual-cloud-performance-benchmark-research
|
||||
[7]: https://www.networkworld.com/article/3223692/what-is-a-data-centerhow-its-changed-and-what-you-need-to-know.html
|
||||
[8]: https://www.facebook.com/NetworkWorld/
|
||||
[9]: https://www.linkedin.com/company/network-world
|
@ -1,222 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (robsean)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (7 Java tips for new developers)
|
||||
[#]: via: (https://opensource.com/article/19/10/java-basics)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
7 Java tips for new developers
|
||||
======
|
||||
If you're just getting started with Java programming, here are seven
|
||||
basics you need to know.
|
||||
![Coffee and laptop][1]
|
||||
|
||||
Java is a versatile programming language used, in some way, in nearly every industry that touches a computer. Java's greatest power is that it runs in a Java Virtual Machine (JVM), a layer that translates Java code into bytecode compatible with your operating system. As long as a JVM exists for your operating system, whether that OS is on a server (or [serverless][2], for that matter), desktop, laptop, mobile device, or embedded device, then a Java application can run on it.
|
||||
|
||||
This makes Java a popular language for both programmers and users. Programmers know that they only have to write one version of their software to end up with an application that runs on any platform, and users know that an application will run on their computer regardless of what operating system they use.
|
||||
|
||||
Many languages and frameworks are cross-platform, but none deliver the same level of abstraction. With Java, you target the JVM, not the OS. For programmers, that's the path of least resistance when faced with several programming challenges, but it's only useful if you know how to program Java. If you're just getting started with Java programming, here are seven basic tips you need to know.
|
||||
|
||||
But first, if you're not sure whether you have Java installed, you can find out in a terminal (such as [Bash][3] or [PowerShell][4]) by running:
|
||||
|
||||
|
||||
```
|
||||
$ java --version
|
||||
openjdk 12.0.2 2019-07-16
|
||||
OpenJDK Runtime Environment 19.3 (build 12.0.2+9)
|
||||
OpenJDK 64-Bit Server VM 19.3 (build 12.0.2+9, mixed mode, sharing)
|
||||
```
|
||||
|
||||
If you get an error or nothing in return, then you should install the [Java Development Kit][5] (JDK) to get started with Java development. Or install a Java Runtime Environment ****(JRE) if you just need to run Java applications.
|
||||
|
||||
### 1\. Java packages
|
||||
|
||||
In Java, related classes are grouped into a _package_. The basic Java libraries you get when you download the JDK are grouped into packages starting with **java** or **javax**. Packages serve a similar function as folders on your computer: they provide structure and definition for related elements (in programming terminology, a _namespace_). Additional packages can be obtained from independent coders, open source projects, and commercial vendors, just as libraries can be obtained for any programming language.
|
||||
|
||||
When you write a Java program, you should declare a package name at the top of your code. If you're just writing a simple application to get started with Java, your package name can be as simple as the name of your project. If you're using a Java integrated development environment (IDE), like [Eclipse][6], it generates a sane package name for you when you start a new project.
|
||||
|
||||
|
||||
```
|
||||
package helloworld;
|
||||
|
||||
/**
|
||||
* @author seth
|
||||
* An application written in Java.
|
||||
*/
|
||||
```
|
||||
|
||||
Otherwise, you can determine the name of your package by looking at its path in relation to the broad definition of your project. For instance, if you're writing a set of classes to assist in game development and the collection is called **jgamer**, then you might have several unique classes within it.
|
||||
|
||||
|
||||
```
|
||||
package jgamer.avatar;
|
||||
|
||||
/**
|
||||
* @author seth
|
||||
* An imaginary game library.
|
||||
*/
|
||||
```
|
||||
|
||||
The top level of your package is **jgamer**, and each package inside it is a descendant, such as **jgamer.avatar** and **jgamer.score** and so on. In your filesystem, the structure reflects this, with **jgamer** being the top directory containing the files **avatar.java** and **score.java**.
|
||||
|
||||
### 2\. Java imports
|
||||
|
||||
The most fun you'll ever have as a polyglot programmer is trying to keep track of whether you **include**, **import**, **use**, **require**, or **some other term** a library in whatever programming language you're writing in. Java, for the record, uses the **import** keyword when importing libraries needed for your code.
|
||||
|
||||
|
||||
```
|
||||
package helloworld;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
/**
|
||||
* @author seth
|
||||
* A GUI hello world.
|
||||
*/
|
||||
```
|
||||
|
||||
Imports work based on an environment's Java path. If Java doesn't know where Java libraries are stored on a system, then an import cannot be successful. As long as a library is stored in a system's Java path, then an import can succeed, and a library can be used to build and run a Java application.
|
||||
|
||||
If a library is not expected to be in the Java path (because, for instance, you are writing the library yourself), then the library can be bundled with your application (license permitting) so that the import works as expected.
|
||||
|
||||
### 3\. Java classes
|
||||
|
||||
A Java class is declared with the keywords **public class** along with a unique class name mirroring its file name. For example, in a file **Hello.java** in project **helloworld**:
|
||||
|
||||
|
||||
```
|
||||
package helloworld;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
/**
|
||||
* @author seth
|
||||
* A GUI hello world.
|
||||
*/
|
||||
|
||||
public class Hello {
|
||||
// this is an empty class
|
||||
}
|
||||
```
|
||||
|
||||
You can declare variables and functions inside a class. In Java, variables within a class are called _fields_.
|
||||
|
||||
### 4\. Java methods
|
||||
|
||||
Java methods are, essentially, functions within an object. They are defined as being **public** (meaning they can be accessed by any other class) or **private** (limiting their use) based on the expected type of returned data, such as **void**, **int**, **float**, and so on.
|
||||
|
||||
|
||||
```
|
||||
public void helloPrompt([ActionEvent][7] event) {
|
||||
[String][8] salutation = "Hello %s";
|
||||
|
||||
string helloMessage = "World";
|
||||
message = [String][8].format(salutation, helloMessage);
|
||||
[JOptionPane][9].showMessageDialog(this, message);
|
||||
}
|
||||
|
||||
private int someNumber (x) {
|
||||
return x*2;
|
||||
}
|
||||
```
|
||||
|
||||
When calling a method directly, it is referenced by its class and method name. For instance, **Hello.someNumber** refers to the **someNumber** method in the **Hello** class.
|
||||
|
||||
### 5\. Static
|
||||
|
||||
The **static** keyword in Java makes a member in your code accessible independently of the object that contains it.
|
||||
|
||||
In object-oriented programming, you write code that serves as a template for "objects" that get spawned as the application runs. You don't code a specific window, for instance, but an _instance_ of a window based upon a window class in Java (and modified by your code). Since nothing you are coding "exists" until the application generates an instance of it, most methods and variables (and even nested classes) cannot be used until the object they depend upon has been created.
|
||||
|
||||
However, sometimes you need to access or use data in an object before it is created by the application (for example, an application can't generate a red ball without first knowing that the ball is meant to be red). For those cases, there's the **static** keyword.
|
||||
|
||||
### 6\. Try and catch
|
||||
|
||||
Java is excellent at catching errors, but it can only recover gracefully if you tell it what to do. The cascading hierarchy of attempting to perform an action in Java starts with **try**, falls back to **catch**, and ends with **finally**. Should the **try** clause fail, then **catch** is invoked, and in the end, there's always **finally** to perform some sensible action regardless of the results. Here's an example:
|
||||
|
||||
|
||||
```
|
||||
try {
|
||||
cmd = parser.parse(opt, args);
|
||||
|
||||
if(cmd.hasOption("help")) {
|
||||
HelpFormatter helper = new HelpFormatter();
|
||||
helper.printHelp("Hello <options>", opt);
|
||||
[System][10].exit(0);
|
||||
}
|
||||
else {
|
||||
if(cmd.hasOption("shell") || cmd.hasOption("s")) {
|
||||
[String][8] target = cmd.getOptionValue("tgt");
|
||||
} // else
|
||||
} // fi
|
||||
} catch ([ParseException][11] err) {
|
||||
[System][10].out.println(err);
|
||||
[System][10].exit(1);
|
||||
} //catch
|
||||
finally {
|
||||
new Hello().helloWorld(opt);
|
||||
} //finally
|
||||
} //try
|
||||
```
|
||||
|
||||
It's a robust system that attempts to avoid irrecoverable errors or, at least, to provide you with the option to give useful feedback to the user. Use it often, and your users will thank you!
|
||||
|
||||
### 7\. Running a Java application
|
||||
|
||||
Java files, usually ending in **.java**, theoretically can be run with the **java** command. If an application is complex, however, whether running a single file results in anything meaningful is another question.
|
||||
|
||||
To run a **.java** file directly:
|
||||
|
||||
|
||||
```
|
||||
`$ java ./Hello.java`
|
||||
```
|
||||
|
||||
Usually, Java applications are distributed as Java Archives (JAR) files, ending in **.jar**. A JAR file contains a manifest file specifying the main class, some metadata about the project structure, and all the parts of your code required to run the application.
|
||||
|
||||
To run a JAR file, you may be able to double-click its icon (depending on how you have your OS set up), or you can launch it from a terminal:
|
||||
|
||||
|
||||
```
|
||||
`$ java -jar ./Hello.jar`
|
||||
```
|
||||
|
||||
### Java for everyone
|
||||
|
||||
Java is a powerful language, and thanks to the [OpenJDK][12] project and other initiatives, it's an open specification that allows projects like [IcedTea][13], [Dalvik][14], and [Kotlin][15] to thrive. Learning Java is a great way to prepare to work in a wide variety of industries, and what's more, there are plenty of [great reasons to use it][16].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/10/java-basics
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_cafe_brew_laptop_desktop.jpg?itok=G-n1o1-o (Coffee and laptop)
|
||||
[2]: https://www.redhat.com/en/resources/building-microservices-eap-7-reference-architecture
|
||||
[3]: https://www.gnu.org/software/bash/
|
||||
[4]: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-6
|
||||
[5]: http://openjdk.java.net/
|
||||
[6]: http://www.eclipse.org/
|
||||
[7]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+actionevent
|
||||
[8]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string
|
||||
[9]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+joptionpane
|
||||
[10]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system
|
||||
[11]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+parseexception
|
||||
[12]: https://openjdk.java.net/
|
||||
[13]: https://icedtea.classpath.org/wiki/Main_Page
|
||||
[14]: https://source.android.com/devices/tech/dalvik/
|
||||
[15]: https://kotlinlang.org/
|
||||
[16]: https://opensource.com/article/19/9/why-i-use-java
|
@ -1,236 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (Morisun029)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Demystifying Kubernetes)
|
||||
[#]: via: (https://opensourceforu.com/2019/11/demystifying-kubernetes/)
|
||||
[#]: author: (Abhinav Nath Gupta https://opensourceforu.com/author/abhinav-gupta/)
|
||||
|
||||
Demystifying Kubernetes
|
||||
======
|
||||
|
||||
[![][1]][2]
|
||||
|
||||
_Kubernetes is a production grade open source system for automating deployment, scaling, and the management of containerised applications. This article is about managing containers with Kubernetes._
|
||||
|
||||
‘Containers’ has become one of the latest buzz words. But what does the term imply? Often associated with Docker, a container is defined as a standardised unit of software. Containers encapsulate the software and the environment required to run the software into a single unit that is easily shippable.
|
||||
A container is a standard unit of software that packages the code and all its dependencies so that the application runs quickly and reliably from one computing environment to another. The container does this by creating something called an image, which is akin to an ISO image. A container image is a lightweight, standalone, executable package of software that includes everything needed to run an application — code, runtime, system tools, system libraries and settings.
|
||||
|
||||
Container images become containers at runtime and, in the case of Docker containers, images become containers when they run on a Docker engine. Containers isolate software from the environment and ensure that it works uniformly despite differences in instances across environments.
|
||||
|
||||
**What is container management?**
|
||||
Container management is the process of organising, adding or replacing large numbers of software containers. Container management uses software to automate the process of creating, deploying and scaling containers. This gives rise to the need for container orchestration—a tool that automates the deployment, management, scaling, networking and availability of container based applications.
|
||||
|
||||
**Kubernetes**
|
||||
Kubernetes is a portable, extensible, open source platform for managing containerised workloads and services, and it facilitates both configuration and automation. It was originally developed by Google. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available.
|
||||
|
||||
Google open sourced the Kubernetes project in 2014. Kubernetes builds upon a decade and a half of experience that Google had with running production workloads at scale, combined with best-of-breed ideas and practices from the community, as well as the usage of declarative syntax.
|
||||
|
||||
Some of the common terminologies associated with the Kubernetes ecosystem are listed below.
|
||||
_**Pods:**_ A pod is the basic execution unit of a Kubernetes application – the smallest and simplest unit in the Kubernetes object model that you create or deploy. A pod represents processes running on a Kubernetes cluster.
|
||||
|
||||
A pod encapsulates the running container, storage, network IP (unique) and commands that govern how the container should run. It represents the single unit of deployment within the Kubernetes ecosystem, a single instance of an application which might consist of one or many containers running with tight coupling and shared resources.
|
||||
|
||||
Pods in a Kubernetes cluster can be used in two main ways. The first is pods that run a single container. The ‘one-container-per-pod’ model is the most common Kubernetes use case. The second method involves pods that run multiple containers that need to work together.
|
||||
|
||||
A pod might encapsulate an application composed of multiple co-located containers that are tightly coupled and need to share resources.
|
||||
|
||||
_**ReplicaSet:**_ The purpose of a ReplicaSet is to maintain a stable set of replica pods running at any given time. A ReplicaSet contains information about how many copies of a particular pod should be running. To create multiple pods to match the ReplicaSet criteria, Kubernetes uses the pod template. The link a ReplicaSet has to its pods is via the latter’s metadata.ownerReferences field, which specifies which resource owns the current object.
|
||||
|
||||
_**Services:**_ Services are an abstraction to expose the functionality of a set of pods. With Kubernetes, you don’t need to modify your application to use an unfamiliar service discovery mechanism. Kubernetes gives pods their own IP addresses and a single DNS name for a set of pods, and can load-balance across them.
|
||||
|
||||
One major problem that services solve is the integration of the front-end and back-end of a Web application. Since Kubernetes provides IP addresses behind the scenes to pods, when the latter are killed and resurrected, the IP addresses are changed. This creates a big problem on the front-end side to connect a given back-end IP address to the corresponding front-end IP address. Services solve this problem by providing an abstraction over the pods — something akin to a load balancer.
|
||||
|
||||
_**Volumes:**_ A Kubernetes volume has an explicit lifetime — the same as the pod that encloses it. Consequently, a volume outlives any container that runs within the pod and the data is preserved across container restarts. Of course, when a pod ceases to exist, the volume will cease to exist, too. Perhaps more important than this is that Kubernetes supports many types of volumes, and a pod can use any number of them simultaneously.
|
||||
|
||||
At its core, a volume is just a directory, possibly with some data in it, which is accessible to the containers in a pod. How that directory comes to be, the medium that backs it and its contents are determined by the particular volume type used.
|
||||
|
||||
**Why Kubernetes?**
|
||||
Containers are a good way to bundle and run applications. In a production environment, you need to manage the containers that run the applications and ensure that there is no downtime. For example, if one container goes down, another needs to start. Wouldn’t it be nice if this could be automated by a system?
|
||||
That’s where Kubernetes comes to the rescue! It provides a framework to run distributed systems resiliently. It takes care of scaling requirements, failover, deployment patterns, and more. For example, Kubernetes can easily manage a canary deployment for your system.
|
||||
|
||||
Kubernetes provides users with:
|
||||
1\. Service discovery and load balancing
|
||||
2\. Storage orchestration
|
||||
3\. Automated roll-outs and roll-backs
|
||||
4\. Automatic bin packing
|
||||
5\. Self-healing
|
||||
6\. Secret and configuration management
|
||||
|
||||
**What can Kubernetes do?**
|
||||
In this section we will look at some code examples of how to use Kubernetes when building a Web application from scratch. We will create a simple back-end server using Flask in Python.
|
||||
There are a few prerequisites for those who want to build a Web app from scratch. These are:
|
||||
1\. Basic understanding of Docker, Docker containers and Docker images. A quick refresher can be found at _<https://www.docker.com/sites/default/files/Docker\_CheatSheet\_08.09.2016\_0.pdf>_.
|
||||
2\. Docker should be installed in the system.
|
||||
3\. Kubernetes should be installed in the system. Instructions on how to do so on a local machine can be found at _<https://kubernetes.io/docs/setup/learning-environment/minikube/>_.
|
||||
Now, create a simple directory, as shown in the code snippet below:
|
||||
|
||||
```
|
||||
mkdir flask-kubernetes/app && cd flask-kubernetes/app
|
||||
```
|
||||
|
||||
Next, inside the _flask-kubernetes/app_ directory, create a file called main.py, as shown in the code snippet below:
|
||||
|
||||
```
|
||||
touch main.py
|
||||
```
|
||||
|
||||
In the newly created _main.py,_ paste the following code:
|
||||
|
||||
```
|
||||
from flask import Flask
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route("/")
|
||||
def hello():
|
||||
return "Hello from Kubernetes!"
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host='0.0.0.0')
|
||||
```
|
||||
|
||||
Install Flask in your local using the command below:
|
||||
|
||||
```
|
||||
pip install Flask==0.10.1
|
||||
```
|
||||
|
||||
After installing Flask, run the following command:
|
||||
|
||||
```
|
||||
python app.py
|
||||
```
|
||||
|
||||
This should run the Flask server locally on port 5000, which is the default port for the Flask app, and you can see the output ‘Hello from Kubernetes!’ on *<http://localhost:500*0>.
|
||||
Once the server is running locally, we will create a Docker image to be used by Kubernetes.
|
||||
Create a file with the name Dockerfile and paste the following code snippet in it:
|
||||
|
||||
```
|
||||
FROM python:3.7
|
||||
|
||||
RUN mkdir /app
|
||||
WORKDIR /app
|
||||
ADD . /app/
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
EXPOSE 5000
|
||||
CMD ["python", "/app/main.py"]
|
||||
```
|
||||
|
||||
The instructions in _Dockerfile_ are explained below:
|
||||
|
||||
1\. Docker will fetch the Python 3.7 image from the Docker hub.
|
||||
2\. It will create an app directory in the image.
|
||||
3\. It will set an app as the working directory.
|
||||
4\. Copy the contents from the app directory in the host to the image app directory.
|
||||
5\. Expose Port 5000.
|
||||
6\. Finally, it will run the command to start the Flask server.
|
||||
In the next step, we will create the Docker image, using the command given below:
|
||||
|
||||
```
|
||||
docker build -f Dockerfile -t flask-kubernetes:latest .
|
||||
```
|
||||
|
||||
After creating the Docker image, we can test it by running it locally using the following command:
|
||||
|
||||
```
|
||||
docker run -p 5001:5000 flask-kubernetes
|
||||
```
|
||||
|
||||
Once we are done testing it locally by running a container, we need to deploy this in Kubernetes.
|
||||
We will first verify that Kubernetes is running using the _kubectl_ command. If there are no errors, then it is working. If there are errors, do refer to _<https://kubernetes.io/docs/setup/learning-environment/minikube/>_.
|
||||
|
||||
Next, let’s create a deployment file. This is a yaml file containing the instruction for Kubernetes about how to create pods and services in a very declarative fashion. Since we have a Flask Web application, we will create a _deployment.yaml_ file with both the pods and services declarations inside it.
|
||||
|
||||
Create a file named deployment.yaml and add the following contents to it, before saving it:
|
||||
|
||||
```
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: flask-kubernetes -service
|
||||
spec:
|
||||
selector:
|
||||
app: flask-kubernetes
|
||||
ports:
|
||||
- protocol: "TCP"
|
||||
port: 6000
|
||||
targetPort: 5000
|
||||
type: LoadBalancer
|
||||
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: flask-kubernetes
|
||||
spec:
|
||||
replicas: 4
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: flask-kubernetes
|
||||
spec:
|
||||
containers:
|
||||
- name: flask-kubernetes
|
||||
image: flask-kubernetes:latest
|
||||
imagePullPolicy: Never
|
||||
ports:
|
||||
- containerPort: 5000
|
||||
```
|
||||
|
||||
Use _kubectl_ to send the _yaml_ file to Kubernetes by running the following command:
|
||||
|
||||
```
|
||||
kubectl apply -f deployment.yaml
|
||||
```
|
||||
|
||||
You can see the pods are running if you execute the following command:
|
||||
|
||||
```
|
||||
kubectl get pods
|
||||
```
|
||||
|
||||
Now navigate to _<http://localhost:6000>_, and you should see the ‘Hello from Kubernetes!’ message.
|
||||
That’s it! The application is now running in Kubernetes!
|
||||
|
||||
**What Kubernetes cannot do**
|
||||
Kubernetes is not a traditional, all-inclusive PaaS (Platform as a Service) system. Since Kubernetes operates at the container level rather than at the hardware level, it provides some generally applicable features common to PaaS offerings, such as deployment, scaling, load balancing, logging, and monitoring. Kubernetes provides the building blocks for developer platforms, but preserves user choice and flexibility where it is important.
|
||||
|
||||
* Kubernetes does not limit the types of applications supported. If an application can run in a container, it should run great on Kubernetes.
|
||||
* It does not deploy and build source code.
|
||||
* It does not dictate logging, monitoring, or alerting solutions.
|
||||
* It does not provide or mandate a configuration language/system. It provides a declarative API for everyone’s use.
|
||||
* It does not provide or adopt any comprehensive machine configuration, maintenance, management, or self-healing systems.
|
||||
|
||||
|
||||
|
||||
![Avatar][3]
|
||||
|
||||
[Abhinav Nath Gupta][4]
|
||||
|
||||
The author is a software development engineer at Cleo Software India Pvt Ltd, Bengaluru. He is interested in cryptography, data security, cryptocurrency and cloud computing. He can be reached at [abhi.aec89@gmail.com][5].
|
||||
|
||||
[![][6]][7]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensourceforu.com/2019/11/demystifying-kubernetes/
|
||||
|
||||
作者:[Abhinav Nath Gupta][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensourceforu.com/author/abhinav-gupta/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Gear-kubernetes.jpg?resize=696%2C457&ssl=1 (Gear kubernetes)
|
||||
[2]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Gear-kubernetes.jpg?fit=800%2C525&ssl=1
|
||||
[3]: https://secure.gravatar.com/avatar/f65917facf5f28936663731fedf545c4?s=100&r=g
|
||||
[4]: https://opensourceforu.com/author/abhinav-gupta/
|
||||
[5]: mailto:abhi.aec89@gmail.com
|
||||
[6]: http://opensourceforu.com/wp-content/uploads/2013/10/assoc.png
|
||||
[7]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US
|
@ -0,0 +1,104 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Challenge: Write a bouncy window manager)
|
||||
[#]: via: (https://jvns.ca/blog/2019/11/25/challenge--make-a-bouncy-window-manager/)
|
||||
[#]: author: (Julia Evans https://jvns.ca/)
|
||||
|
||||
Challenge: Write a bouncy window manager
|
||||
======
|
||||
|
||||
Hello! I’m writing a short series of programming challenges with [Julian][1], and this is the first one!
|
||||
|
||||
### the challenge
|
||||
|
||||
![][2]
|
||||
|
||||
**requirements**
|
||||
|
||||
The goal here is to make a very silly Linux window manager that bounces its windows around the screen, like in the gif above.
|
||||
|
||||
**anti-requirements**
|
||||
|
||||
The window manager doesn’t need to do anything else! It doesn’t need to support:
|
||||
|
||||
* moving or resizing windows
|
||||
* switching between windows
|
||||
* minimizing windows
|
||||
* literally any of the other things you might normally expect a window manager to do
|
||||
|
||||
|
||||
|
||||
It turns out implementing this kind of toy window manager is surprisingly approachable!
|
||||
|
||||
### the setup: start with tinywm
|
||||
|
||||
All the instructions here only work on Linux (since this is about writing a Linux window manager).
|
||||
|
||||
**starter kit: tinywm**
|
||||
|
||||
Writing a window manager from scratch seems intimidating (at first I didn’t even know how to start!). But then I found **[tinywm][3]**, which is a tiny window manager written in only **50 lines of C**. This is a GREAT starting point and there’s an annotated version of the source code which explains a lot of the details. There’s a Python version of tinywm too, but I wasn’t able to get it to work.
|
||||
|
||||
I did this challenge by modifying [tinywm][3] and it worked really well.
|
||||
|
||||
**tools**
|
||||
|
||||
* **Xephyr** lets you embed an X session in a window in your regular desktop, so that you can develop your toy window manager without breaking your usual desktop. I ran it like this: `Xephyr -ac -screen 1280x1024 -br -reset -terminate 2> /dev/null :1 &`
|
||||
* You can start an xterm in the Xephyr desktop with `xterm -display :1`
|
||||
* I compiled my window manager with `gcc bouncewm.c -g -o bouncewm -lX11` and ran it with `env DISPLAY=:1 ./bouncewm`
|
||||
* **xtrace** lets you trace all requests to the X windows system that your window manager is making. I found it really helpful when debugging. (run it like `xtrace ./bouncewm`)
|
||||
|
||||
|
||||
|
||||
**documentation**
|
||||
|
||||
Some useful references:
|
||||
|
||||
* the [dwm source code][4] (dwm is a 2000-line-of-C window manager)
|
||||
* the [Xlib programming manual][5]
|
||||
|
||||
|
||||
|
||||
If you’re not comfortable writing C, there are also libraries that let you work with X in other languages. I personally found C easier to use because a lot of the window manager documentation and examples I found were for the Xlib C library.
|
||||
|
||||
### my experience: 5 hours, 50 lines of code
|
||||
|
||||
To give you a very rough idea of the difficulty of this exercise: I did this in 4 or 5 hours this morning and last night, producing the window manager you see in the gif at the top of the blog post (which is 50 lines of code). I’d never looked at the source code for a window manager before yesterday.
|
||||
|
||||
As usual when working with a new library I spent most of that time being confused about various basic things about how X works. (and as a result I learned several new things about X!)
|
||||
|
||||
For me this challenge was a fun way to:
|
||||
|
||||
* learn some basics about the X window system protocol (I’ve been using window managers for 15 years, today I got to write one!)
|
||||
* research an unfamiliar library (“ooh, what does this function do?”)
|
||||
* use a C library, since I don’t usually write C
|
||||
|
||||
|
||||
|
||||
### send me your solution if you do this!
|
||||
|
||||
I’ll post the solution I came up in a week. If you think this window manager challenge sounds fun and end up doing it, I’d love it if you sent me your solution (to [[email protected]][6])!
|
||||
|
||||
I’d be delighted to post any solutions you send me in the solutions blog post.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://jvns.ca/blog/2019/11/25/challenge--make-a-bouncy-window-manager/
|
||||
|
||||
作者:[Julia Evans][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://jvns.ca/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: http://www.cipht.net/2017/10/03/are-jump-tables-always-fastest.html
|
||||
[2]: https://jvns.ca/images/bouncewm.gif
|
||||
[3]: http://incise.org/tinywm.html
|
||||
[4]: https://git.suckless.org/dwm/file/dwm.c.html
|
||||
[5]: https://tronche.com/gui/x/xlib/
|
||||
[6]: https://jvns.ca/cdn-cgi/l/email-protection
|
@ -0,0 +1,61 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Calculator N+ is an open source scientific calculator for your smartphone)
|
||||
[#]: via: (https://opensource.com/article/19/11/calculator-n-mobile)
|
||||
[#]: author: (Ricardo Berlasso https://opensource.com/users/rgb-es)
|
||||
|
||||
Calculator N+ is an open source scientific calculator for your smartphone
|
||||
======
|
||||
The Android app does a wide range of advanced mathematical functions in
|
||||
the palm of your hand.
|
||||
![scientific calculator][1]
|
||||
|
||||
Mobile phones are becoming more powerful every day, so it is no surprise that they can beat most computers from the not-so-distant past. This also means the tools available on them are getting more powerful every day.
|
||||
|
||||
Previously, I wrote about [scientific calculators for the Linux desktop][2], and I'm following that up here with information about [Calculator N+][3], an awesome GPL v3.0-licensed computer algebra system (CAS) app for Android devices.
|
||||
|
||||
Calculator N+ is presented as a "powerful calculator for Android," but that's a humble statement; the app not only works with arbitrary precision, displaying results with roots and fractions in all their glory, it does a _lot_ more.
|
||||
|
||||
Finding polynomial roots? Check. Factorization? Check. Symbolic derivatives, integrals, and limits? Check. Number theory (modular arithmetic, combinatorics, prime factorization)? Check.
|
||||
|
||||
You can also solve systems of equations, simplify expressions (including trigonometric ones), convert units… you name it!
|
||||
|
||||
![Calculator N+ graphical interface][4]
|
||||
|
||||
Results are output in LaTeX. The menu in the top-left provides many powerful functions ready to use with a simple touch. Also in that menu, you'll find Help files for all of the app's functions. At the top-right of the screen, you can toggle between exact and decimal representation. Finally, tapping the blue bar at the bottom of the screen gives you access to the whole library of functions available in the app. But be careful! If you are not a mathematician, physicist, or engineer, such a long list may seem overwhelming.
|
||||
|
||||
All of this power comes from the [Symja library][5], another great GPL 3 project.
|
||||
|
||||
Both projects are under active development, and they are getting better with each version. In particular, version 3.4.6 of Calculator N+ gets a major leap in user interface (UI) quality. And yes, there are still some rough corners here and there, but taming this much power in the tiny UI of a smartphone is a difficult task, and I think the app developers are solving its remaining issues quite well. Kudos to them!
|
||||
|
||||
If you are a teacher, a student, or work on a STEM field, check out Calculator N+. It's free, no ads, open source, and covers all your math needs. (Except, of course, during math exams, where smartphones should never be allowed to prevent cheating.)
|
||||
|
||||
Calculator N+ is available in the [Google Play Store][6], or you can [build it from source code][7] using the instructions on the GitHub page.
|
||||
|
||||
If you know any other useful open source apps for science or engineering, let us know in the comments.
|
||||
|
||||
The app makes use of the sensors on your phone and offers a digital science notebook to record your...
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/11/calculator-n-mobile
|
||||
|
||||
作者:[Ricardo Berlasso][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/rgb-es
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/calculator_money_currency_financial_tool.jpg?itok=2QMa1y8c (scientific calculator)
|
||||
[2]: https://opensource.com/article/18/1/scientific-calculators-linux
|
||||
[3]: https://github.com/tranleduy2000/ncalc
|
||||
[4]: https://opensource.com/sites/default/files/uploads/calculatornplus_sqrt-frac.png (Calculator N+ graphical interface)
|
||||
[5]: https://github.com/axkr/symja_android_library
|
||||
[6]: https://play.google.com/store/apps/details?id=com.duy.calculator.free
|
||||
[7]: https://github.com/tranleduy2000/ncalc/blob/master/README.md
|
233
sources/tech/20191126 Make Lua development easy with Luarocks.md
Normal file
233
sources/tech/20191126 Make Lua development easy with Luarocks.md
Normal file
@ -0,0 +1,233 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Make Lua development easy with Luarocks)
|
||||
[#]: via: (https://opensource.com/article/19/11/getting-started-luarocks)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
Make Lua development easy with Luarocks
|
||||
======
|
||||
Luarocks makes it easy to get started with Lua, a lightweight,
|
||||
efficient, and embeddable scripting language.
|
||||
![Coding on a computer][1]
|
||||
|
||||
Bash too basic? Too much whitespace in Python? Go too corporate?
|
||||
|
||||
You should try Lua, a lightweight, efficient, and embeddable scripting language supporting procedural programming, object-oriented programming, functional programming, data-driven programming, and data description. And best of all, it uses explicit syntax for scoping!
|
||||
|
||||
Lua is also small. Lua's source code is just 24,000 lines of C, the Lua interpreter (on 64-bit Linux) built with all standard Lua libraries is 247K, and the Lua library is 421K.
|
||||
|
||||
You might think that such a small language must be too simplistic to do any real work, but in fact Lua has a vast collection of third-party libraries (including GUI toolkits), it's used extensively in video game and film production for 3D shaders, and is a common scripting language for video game engines. To make it easy to get started with Lua, there's even a package manager called [Luarocks][2].
|
||||
|
||||
### What is Luarocks?
|
||||
|
||||
Python has PIP, Ruby has Gems, Java has Maven, Node has npm, and Lua has Luarocks. Luarocks is a website and a command. The website is home to open source libraries available for programmers to add to their Lua projects. The command searches the site and installs libraries (defined as "rocks") upon demand.
|
||||
|
||||
### What is a programming library?
|
||||
|
||||
If you're new to programming, you might think of a "library" as just a place where books are stored. Programming libraries ("lib" or "libs" for short) are a little like a book library in the sense that both of these things contain information that someone else has already worked to discover, and which you can borrow so you have to do less work.
|
||||
|
||||
For example, if you were writing code that measures how much stress a special polymer can withstand before breaking, you might think you'd have to be pretty clever with math. But if there was already an open source library specifically designed for exactly that sort of calculation, then you could include that library in your code and let it solve that problem for you (provided you give the library's internal functions the numbers it needs in order to perform an accurate calculation).
|
||||
|
||||
In open source programming, you can install libraries freely and use other people's work at will. Luarocks is the mechanism for Lua that makes it quick and easy to find and use a Lua library.
|
||||
|
||||
### Installing Luarocks
|
||||
|
||||
The **luarocks** command isn't actually _required_ to use packages from the Luarocks website, but it does keep you from having to leave your text editor and venture onto the worldwide web [of potential distractions]. To install Luarocks, you first need to install Lua.
|
||||
|
||||
Lua is available from [lua.org][3] or, on Linux, from your distribution's software repository. For example, on Fedora, CentOS, or RHEL:
|
||||
|
||||
|
||||
```
|
||||
`$ sudo dnf install lua`
|
||||
```
|
||||
|
||||
On Debian and Ubuntu:
|
||||
|
||||
|
||||
```
|
||||
`$ sudo apt install lua`
|
||||
```
|
||||
|
||||
On Windows and Mac, you can download and install Lua from the website.
|
||||
|
||||
Once Lua is installed, install Luarocks. If you're on Linux, the **luarocks** command is available in your distribution's repository.
|
||||
|
||||
On Mac, you can install it with [Brew][4] or compile from source:
|
||||
|
||||
|
||||
```
|
||||
$ wget <https://luarocks.org/releases/luarocks-X.Y.Z.tar.gz>
|
||||
$ tar zxpf luarocks-X.Y.Z.tar.gz
|
||||
$ cd luarocks-X.Y.Z
|
||||
$ ./configure; sudo make bootstrap
|
||||
```
|
||||
|
||||
On Windows, follow the [install instructions][5] on the Luarocks wiki.
|
||||
|
||||
### Search for a library with Luarocks
|
||||
|
||||
The typical usage of the **luarocks** command, from the perspective of a user rather than a developer, involves searching for a library required by some Lua application you want to run and installing that library.
|
||||
|
||||
To search for the Lua package **luasec** (a library providing HTTPS support for **luarocks**), try this command:
|
||||
|
||||
|
||||
```
|
||||
$ luarocks search luasec
|
||||
Warning: falling back to curl -
|
||||
install luasec to get native HTTPS support
|
||||
|
||||
Search results:
|
||||
===============
|
||||
|
||||
Rockspecs and source rocks:
|
||||
\---------------------------
|
||||
|
||||
luasec
|
||||
0.9-1 (rockspec) - <https://luarocks.org>
|
||||
0.9-1 (src) - <https://luarocks.org>
|
||||
0.8.2-1 (rockspec) - <https://luarocks.org>
|
||||
[...]
|
||||
```
|
||||
|
||||
### Install a library with Luarocks
|
||||
|
||||
To install the **luasec** library:
|
||||
|
||||
|
||||
```
|
||||
$ luarocks install --local luasec
|
||||
[...]
|
||||
gcc -shared -o ssl.so -L/usr/lib64
|
||||
src/config.o src/ec.o src/x509.o [...]
|
||||
-L/usr/lib -Wl,-rpath,/usr/lib: -lssl -lcrypto
|
||||
|
||||
luasec 0.9-1 is now installed in
|
||||
/home/seth/.luarocks (license: MIT)
|
||||
```
|
||||
|
||||
You can install Lua libraries locally or on a systemwide basis. A _local_ install indicates that the Lua library you install is available to you, but no other user of the computer. If you share your computer with someone else, and you each have your own [login account][6], then you probably want to install a library systemwide. However, if you're the only user of your computer, it's a good habit to install libraries locally, if only because that's the appropriate method when you develop with Lua.
|
||||
|
||||
If you're _developing_ a Lua application, then you probably want to install a library to a project directory instead. In Luarocks terminology, this is a _tree_. Your default tree when installing libraries locally is **$HOME/.luarocks**, but you can redefine it arbitrarily.
|
||||
|
||||
|
||||
```
|
||||
$ mkdir local
|
||||
$ luarocks --tree=./local install cmark
|
||||
Installing <https://luarocks.org/cmark-0.YY.0-1.src.rock>
|
||||
gcc -O2 -fPIC -I/usr/include -c cmark_wrap.c [..]
|
||||
gcc -O2 -fPIC -I/usr/include -c ext/blocks.c -o ext/blocks.o [..]
|
||||
[...]
|
||||
No existing manifest. Attempting to rebuild...
|
||||
cmark 0.29.0-1 is now installed in
|
||||
/home/seth/downloads/osdc/example-lua/./local
|
||||
(license: BSD2)
|
||||
```
|
||||
|
||||
The library (in this example, the **cmark** library) is installed to the path specified by the **\--tree** option. You can verify it by listing the contents of the destination:
|
||||
|
||||
|
||||
```
|
||||
$ find ./local/ -type d -name "cmark"
|
||||
./local/share/lua/5.1/cmark
|
||||
./local/lib/luarocks/rocks/cmark
|
||||
```
|
||||
|
||||
You can use the library in your Lua code by defining the **package.path** variable to point to your local rocks directory:
|
||||
|
||||
|
||||
```
|
||||
package.path = package.path .. ';local/share/lua/5.3/?.lua'
|
||||
|
||||
require("cmark")
|
||||
```
|
||||
|
||||
### Getting information about an installed rock
|
||||
|
||||
You can see information about an installed rock with the **show** option:
|
||||
|
||||
|
||||
```
|
||||
$ luarocks show luasec
|
||||
LuaSec 0.9-1 - A binding for OpenSSL library
|
||||
to provide TLS/SSL communication over LuaSocket.
|
||||
|
||||
This version delegates to LuaSocket the TCP
|
||||
connection establishment between
|
||||
the client and server. Then LuaSec uses this
|
||||
connection to start a secure TLS/SSL session.
|
||||
|
||||
License: MIT
|
||||
Homepage: <https://github.com/brunoos/luasec/wiki>
|
||||
Installed in: /home/seth/.luarocks
|
||||
[...]
|
||||
```
|
||||
|
||||
This provides you with a summary of what a library provides from a user's perspective, displays the project homepage in case you want to investigate further, and shows you where the library is installed. In this example, it's installed in my home directory in a **.luarocks** folder. This assures me that it's installed locally, which means that if I migrate my home directory to a different computer, I'll retain my Luarocks configuration and installs.
|
||||
|
||||
### Get a list of installed rocks
|
||||
|
||||
You can list all installed rocks on your system with the **list** option:
|
||||
|
||||
|
||||
```
|
||||
$ luarocks list
|
||||
|
||||
Installed rocks:
|
||||
\----------------
|
||||
|
||||
luasec
|
||||
0.9-1 (installed) - /home/seth/.luarocks/lib/luarocks/rocks
|
||||
|
||||
luasocket
|
||||
3.0rc1-2 (installed) - /home/seth/.luarocks/lib/luarocks/rocks
|
||||
|
||||
luce
|
||||
scm-0 (installed) - /home/seth/.luarocks/lib/luarocks/rocks
|
||||
|
||||
tekui
|
||||
1.07-1 (installed) - /home/seth/.luarocks/lib/luarocks/rocks
|
||||
```
|
||||
|
||||
This displays the rocks you have installed in the default install location. Developers can override this by using the **\--tree** option to redefine the active tree.
|
||||
|
||||
### Remove a rock
|
||||
|
||||
If you want to remove a rock, you can do that with Luarocks using the **remove** option:
|
||||
|
||||
|
||||
```
|
||||
`$ luarocks remove --local cmark`
|
||||
```
|
||||
|
||||
This removes a library (in this example, the **cmark** library) from your local tree. Developers can override this by using the **\--tree** option to redefine the active tree.
|
||||
|
||||
If you want to remove _all_ the rocks you have installed, use the **purge** option instead.
|
||||
|
||||
### Luarocks rocks
|
||||
|
||||
Whether you're a user exploring exciting new Lua applications and need to install some dependencies or you're a developer using Lua to create exciting new applications, Luarocks makes your job easy. Lua is a beautiful and simple language, and Luarocks is perfectly suited to be its package manager. Give both a try today!
|
||||
|
||||
Discussing Tarantool this year at the Percona Live Data Performance Conference.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/11/getting-started-luarocks
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer)
|
||||
[2]: http://luarocks.org
|
||||
[3]: http://lua.org
|
||||
[4]: http://brew.sh
|
||||
[5]: https://github.com/luarocks/luarocks/wiki/Installation-instructions-for-Windows
|
||||
[6]: https://opensource.com/article/19/11/add-user-gui-linux
|
221
translated/tech/20191007 7 Java tips for new developers.md
Normal file
221
translated/tech/20191007 7 Java tips for new developers.md
Normal file
@ -0,0 +1,221 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (robsean)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (7 Java tips for new developers)
|
||||
[#]: via: (https://opensource.com/article/19/10/java-basics)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
给新 Java 开发者的 7 点提示
|
||||
======
|
||||
如果你只是刚刚开始 Java 编程,这里有七个你需要知道的基础知识。
|
||||
![Coffee and laptop][1]
|
||||
|
||||
Java 是一个多功能的编程语言,在某种程度上,是一种通用的编程语言,在某种程度上,在几乎所有可能涉及计算机的行业。 Java 的最大优势是,它运行在一个 Java 虚拟机(JVM)中,一个翻译 Java 代码为操作系统兼容的字节码的层。只要有一个 JVM 存在于你的操作系统上,不管这个操作系统是在一个服务器 (或 [无服务器][2], 也是同样的), 桌面电脑,笔记本电脑,移动设备,或嵌入式设备,那么,一个 Java 应用程序可以运行在它上面。
|
||||
|
||||
这使得 Java 成为程序员和用户中间的一种流行语言。程序员知道,他们只需要写一个软件版本就能最终得到一个在任何平台上运行是应用程序,用户知道,一个应用程序将运行在他们的计算机上运行,而不用管他们使用什么样的操作系统。
|
||||
|
||||
很多语言和框架是跨平台的,但是没有实现同样的抽象层。使用 Java ,你的目标是 JVM ,而不是操作系统。对于程序员,当面对一些编程难题时,这些是阻力最小的线路,但是它仅在当你知道如何编程 Java 时有用。如果你刚开始 Java 编程,这里有你需要知道是七个基础的提示。
|
||||
|
||||
但是,首先,如果你不确定是否你安装了 Java ,你可以在一个终端(例如 [Bash][3] 或 [PowerShell][4]) 中找出来,通过运行:
|
||||
|
||||
|
||||
```
|
||||
$ java --version
|
||||
openjdk 12.0.2 2019-07-16
|
||||
OpenJDK Runtime Environment 19.3 (build 12.0.2+9)
|
||||
OpenJDK 64-Bit Server VM 19.3 (build 12.0.2+9, mixed mode, sharing)
|
||||
```
|
||||
|
||||
如果你获得一个错误,或未返回任何东西,那么你应该安装 [Java Development Kit][5] (JDK) 来开始 Java 开发。或者,安装一个 Java 运行时环境 ****(JRE) ,如果你只需要来运行 Java 应用程序。
|
||||
|
||||
### 1\. Java 软件包
|
||||
|
||||
在 Java 语言中,相关的类被分组到一个 _软件包_ 中。当你下载 JDK 时所获得的基本的 Java 库将被分组到以 **java** 或 **javax** 开头的软件包中。软件包提供一种类似于计算机上的文件夹的功能:它们为相关的元素提供结构和定义 (在编程术语中, _命名空间_)。额外的软件包可以从独立的代码,开源项目和商业供应商获得,就想可以为任何编程语言获得库一样。
|
||||
|
||||
当你写一个 Java 程序时,你应该在你的代码是顶部声明一个软件包。 如果你只是编写一个简单的应用程序来开始 Java ,你的软件包名称可以和你的项目的名称一样简单。如果你正在使用一个 Java 集成开发环境,像 [Eclipse][6] ,当你启动一个新的项目时,它为你生成一个合乎情理的软件包名称。
|
||||
|
||||
|
||||
```
|
||||
package helloworld;
|
||||
|
||||
/**
|
||||
* @author seth
|
||||
* An application written in Java.
|
||||
*/
|
||||
```
|
||||
|
||||
除此之外,你可以通过查找它的关系到你的项目的广泛定义的路径来查明你的软件包的名称。例如,如果你正在写一组类来帮助游戏开发,并且集合被称为 **jgamer** ,那么你可能在其中有一些唯一的类。
|
||||
|
||||
|
||||
```
|
||||
package jgamer.avatar;
|
||||
|
||||
/**
|
||||
* @author seth
|
||||
* An imaginary game library.
|
||||
*/
|
||||
```
|
||||
|
||||
你的软件包的顶层是 **jgamer** ,并且在其内部中每个软件包都是一个独立的派生物,例如 **jgamer.avatar** 和 **jgamer.score** 等等。在你的文件系统找那个,该结构反映这一点,**jgamer** 是包含文件 **avatar.java** 和 **score.java** 的顶级目录。
|
||||
|
||||
### 2\. Java 导入
|
||||
|
||||
作为一名通晓多种语言的程序员,最大的乐趣是尝试是否跟踪 **include** , **import** , **use** , **require** ,或 **一些其它术语** 。无论你正在使用何种编程语言编写一个库。在 Java 中,对于记录,当导入你的代码的需要的库时,使用 **import** 关键字。
|
||||
|
||||
|
||||
```
|
||||
package helloworld;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
/**
|
||||
* @author seth
|
||||
* A GUI hello world.
|
||||
*/
|
||||
```
|
||||
|
||||
导入工作基于一个环境的 Java 路径。如果 Java 不知道Java 库存储在系统上的何处,那么,导入可能不成功。只要一个库被存储在系统的 Java 路径中,那么导入能够成功,并且库能够被用于构建和运行一个 Java 应用程序。
|
||||
|
||||
如果不希望一个库在 Java 路径中(因为,例如,你正在写你自己的库),那么库可以与你的应用程序绑定在一起(协议许可),以便导入工作按预期工作。
|
||||
|
||||
### 3\. Java 类
|
||||
|
||||
一个 Java 类被使用关键字 **public class** 声明,以及一个唯一的反应它的文件名称的类名称。例如,在项目 **helloworld** 中的一个文件**Hello.java** 中:
|
||||
|
||||
|
||||
```
|
||||
package helloworld;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
/**
|
||||
* @author seth
|
||||
* A GUI hello world.
|
||||
*/
|
||||
|
||||
public class Hello {
|
||||
// this is an empty class
|
||||
}
|
||||
```
|
||||
|
||||
你可以在一个类内部声明变量和函数。在 Java 中,在一个类中的变量被称为 _终端_ 。
|
||||
|
||||
### 4\. Java 方法
|
||||
|
||||
Java 方法本质上是在一个对象中的函数。 基于预期返回的数据类型,它们被定义为 **public** (意味着它们可以被任何其它类访问) 或 **private** (限制它们使用),例入 **void** , **int** , **float** 等等。
|
||||
|
||||
|
||||
```
|
||||
public void helloPrompt([ActionEvent][7] event) {
|
||||
[String][8] salutation = "Hello %s";
|
||||
|
||||
string helloMessage = "World";
|
||||
message = [String][8].format(salutation, helloMessage);
|
||||
[JOptionPane][9].showMessageDialog(this, message);
|
||||
}
|
||||
|
||||
private int someNumber (x) {
|
||||
return x*2;
|
||||
}
|
||||
```
|
||||
|
||||
当直接调用一个方法时,它被它的类和方法名称引用。例如, **Hello.someNumber** 指向在 **Hello** 类中的 **someNumber** 方法。
|
||||
|
||||
### 5\. 静态的
|
||||
|
||||
在 Java 中的 **static** 关键字使在你的代码中的一个成员独立地访问包含它的对象。
|
||||
|
||||
在面向对象编程中,在应用程序运行时,你所编写代码将作为所生成“对象”的一个模板。你不需要编写一个明确的窗口,例如,在 Java(和你所修改的代码)中,基于一个窗口类的一个窗口的一个 _实例_ 。因为,你所编码的东西将不“存在”,直到应用程序生成它的一个实例为止,大多数的方法和变量(和甚至嵌套类)将不能被使用,直到它们依赖的对象在被创建为止。
|
||||
|
||||
然而,有时,在它被通过应用程序创建前,你需要访问或使用在一个对象中的数据。(例如,没有事先知道球是红色时,一个应用程序不能生成一个红色的球)。对于这些情况,这里有 **static** 关键字。
|
||||
|
||||
### 6\. Try 和 catch
|
||||
|
||||
Java 擅长捕捉错误,但是,你告诉它做什么,它才能优雅地恢复。在 Java 中,以 **try** 开头来尝试级联层次结构执行一个动作,略微退回到 **catch** ,并以 **finally** 结尾。可能 **try** 分句会不执行,那么 **catch** 被引用,在结尾,不管结果如何,总是由 **finally** 来执行一些合理的动作。这里是一个示例:
|
||||
|
||||
|
||||
```
|
||||
try {
|
||||
cmd = parser.parse(opt, args);
|
||||
|
||||
if(cmd.hasOption("help")) {
|
||||
HelpFormatter helper = new HelpFormatter();
|
||||
helper.printHelp("Hello <options>", opt);
|
||||
[System][10].exit(0);
|
||||
}
|
||||
else {
|
||||
if(cmd.hasOption("shell") || cmd.hasOption("s")) {
|
||||
[String][8] target = cmd.getOptionValue("tgt");
|
||||
} // else
|
||||
} // fi
|
||||
} catch ([ParseException][11] err) {
|
||||
[System][10].out.println(err);
|
||||
[System][10].exit(1);
|
||||
} //catch
|
||||
finally {
|
||||
new Hello().helloWorld(opt);
|
||||
} //finally
|
||||
} //try
|
||||
```
|
||||
|
||||
它是一个健壮的系统,它试图避免无法挽回的错误,或者,至少,向你提供给予用户有用的反馈的选项。经常使用它,你的用户将会感谢你!
|
||||
|
||||
### 7\. 运行一个 Java 应用程序
|
||||
|
||||
Java 文件,通常以 **.java** 结尾,理论上说,可以使用 **java** 命令运行。然而,如果一个应用程序是复杂的,运行一个单个文件是否会造成有意义的事将是另外一个问题。
|
||||
|
||||
来直接运行一个 **.java** 文件:
|
||||
|
||||
|
||||
```
|
||||
`$ java ./Hello.java`
|
||||
```
|
||||
|
||||
通常,Java 应用程序以 Java 存档 (JAR) 文件的形式分发,以 **.jar** 结尾。一个 JAR 文件包含一个 manifest 文件,指定主类,项目结构的一些元数据,以及运行应用程序所需的你的代码的所有部分。
|
||||
|
||||
为运行一个 JAR 文件,你可以双击它的图标(取决于你的操作系统设置), 或者,你可以从一个终端中启动它:
|
||||
|
||||
|
||||
```
|
||||
`$ java -jar ./Hello.jar`
|
||||
```
|
||||
|
||||
### 面向所有人的 Java
|
||||
|
||||
Java 是一种强大的的原因,归因于 [OpenJDK][12] 项目和其它的新方案,它是一种开放式规范,允许像 [IcedTea][13], [Dalvik][14],和 [Kotlin][15] 项目的茁壮成长。学习 Java 是一种准备在各种行业中工作的极好的方法,另外,这里有很多[极好的原因来使用它][16]。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/10/java-basics
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[robsean](https://github.com/robsean)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_cafe_brew_laptop_desktop.jpg?itok=G-n1o1-o (Coffee and laptop)
|
||||
[2]: https://www.redhat.com/en/resources/building-microservices-eap-7-reference-architecture
|
||||
[3]: https://www.gnu.org/software/bash/
|
||||
[4]: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-6
|
||||
[5]: http://openjdk.java.net/
|
||||
[6]: http://www.eclipse.org/
|
||||
[7]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+actionevent
|
||||
[8]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string
|
||||
[9]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+joptionpane
|
||||
[10]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system
|
||||
[11]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+parseexception
|
||||
[12]: https://openjdk.java.net/
|
||||
[13]: https://icedtea.classpath.org/wiki/Main_Page
|
||||
[14]: https://source.android.com/devices/tech/dalvik/
|
||||
[15]: https://kotlinlang.org/
|
||||
[16]: https://opensource.com/article/19/9/why-i-use-java
|
231
translated/tech/20191107 Demystifying Kubernetes.md
Normal file
231
translated/tech/20191107 Demystifying Kubernetes.md
Normal file
@ -0,0 +1,231 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (Morisun029)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Demystifying Kubernetes)
|
||||
[#]: via: (https://opensourceforu.com/2019/11/demystifying-kubernetes/)
|
||||
[#]: author: (Abhinav Nath Gupta https://opensourceforu.com/author/abhinav-gupta/)
|
||||
|
||||
揭开 Kubernetes 的神秘面纱
|
||||
======
|
||||
|
||||
[![][1]][2]
|
||||
|
||||
_Kubernetes 是一款生产级的开源系统,用于容器化应用程序的自动部署,扩展和管理。本文关于使用 Kubernetes 来管理容器。_
|
||||
|
||||
|
||||
“容器”已成为最新的流行语之一。 但是,这个词到底意味着什么呢? 说起“容器”,人们通常会把它和 Docker 联系起来,Docker 是一个被定义为软件的标准化单元容器。 该容器将软件和运行软件所需的环境封装到一个易于交付的单元中。 容器是一个软件的标准单元,用它来打包代码及其所有依赖项,这样应用程序就可以从一个计算环境快速可靠地运行到另一个计算环境。 容器通过创建类似于ISO 映像的方式来实现此目的。 容器镜像是一个轻量级的,独立的,可执行的软件包,其中包含运行应用程序所需的所有信息,包括代码,运行时,系统工具,系统库和设置。
|
||||
|
||||
容器镜像在运行时变成容器,对于Docker 容器,映像在 Docker 引擎上运行时变成容器。 容器将软件与环境隔离开来,确保不同环境下的实例,都可以正常运行。
|
||||
|
||||
**什么是容器管理?**
|
||||
容器管理是组织,添加或替换大量软件容器的过程。 容器管理使用软件来自动化创建,部署和扩展容器。 这一过程就需要容器编排。容器编排是一个基于应用程序进行自动部署,管理,扩展,联网的可用容器。
|
||||
|
||||
**Kubernetes**
|
||||
Kubernetes 是一个可移植的,可扩展的开源平台,用于管理容器化的工作负载和服务,它有助于配置和自动化。 它最初由 Google 开发, 拥有一个庞大且快速增长的生态系统。 Kubernetes 的服务,技术支持和工具得到广泛应用。
|
||||
|
||||
Google 在2014年将 Kubernetes 项目开源化。Kubernetes 建立在 Google 十五年大规模运行生产工作负载的经验基础上并结合了社区中最好的想法和实践以及声明式句法的使用。
|
||||
下面列出了与Kubernetes生态系统相关的一些常用术语。
|
||||
|
||||
_**Pods:**_ pod 是 Kubernetes 应用程序的基本执行单元,是你创建或部署的 Kubernetes 对象模型中的最小和最简单的单元。pod 代表在 Kubernetes 集群上运行的进程。
|
||||
Pod 将运行中的容器,存储,网络IP(唯一)和控制容器应如何运行的命令封装起来。它代表 Kubernetes 生态系统内的单个部署单元,代表一个应用程序的单个实例,该程序可能包含一个或多个紧密耦合并共享资源的容器。
|
||||
|
||||
Kubernetes 集群中的Pod有两种主要的使用方式。 第一种是运行单个容器。 即“一个容器一个pod”,这种方式是最常见的。 第二种是运行多个需要一起工作的容器。
|
||||
Pod 可能封装一个应用程序,该应用程序由紧密关联且需要共享资源的多个同位容器组成。
|
||||
|
||||
_**ReplicaSet:**_ ReplicaSet 的目的是维护在任何给定时间运行的一组稳定的副本容器集。 ReplicaSet 包含有关一个特定 Pod 应该运行多少个副本的信息。 为了创建多个Pod 以匹配 ReplicaSet 条件,Kubernetes 使用 Pod 模板。 ReplicaSet 与其 pod 的链接是通过后者的 metas.ownerReferences 字段实现,该字段指定哪个资源拥有当前对象。
|
||||
|
||||
_**Services:**_ 服务是公开一组 Pod 功能的抽象。 使用 Kubernetes,你无需修改应用程序即可使用陌生的服务发现机制。 Kubernetes 为 Pod 提供了自己的IP地址和一组Pod 的单个DNS 名称,并且可以在它们之间负载平衡。
|
||||
|
||||
服务解决的一个主要问题是Web应用程序前端和后端的集成。 由于 Kubernetes 将幕后 IP 地址提供给 Pod,因此当 Pod 被杀死并复活时,IP 地址会更改。 这给给定的后端 IP 地址连接到相应的前端 IP 地址带来一个大问题。 服务通过在 Pod 上提供抽象来解决此问题,类似于负载均衡器。
|
||||
|
||||
_**Volumes:**_ Kubernetes Volumes 具有明确的生命周期-与包围它的 Pod 相同。 因此,Volumes 超过了pod 中运行的任何容器的寿命,并且在容器重新启动后保留了数据。 当然,当 pod 不存在时,该体积也将不再存在。 也许比这更重要的是 Kubernetes 支持多种类型的 Volumes,并且 Pod 可以同时使用任意数量的 Volumes。
|
||||
|
||||
Volumes 的核心只是一个目录,其中可能包含一些数据,pod 中的容器可以访问该目录。 该目录是如何产生的, 它后端基于什么存储介质,其中的数据内容是什么,这些都由使用的特定 volumes 类型来决定的。
|
||||
|
||||
**为什么选择 Kubernetes?**
|
||||
容器是捆绑和运行应用程序的好方法。 在生产环境中,你需要管理运行应用程序的容器,并确保没有停机时间。 例如,如果一个容器发生故障,则需要启动另一个容器。 如果由系统自动实现这一操作,岂不是更好? Kubernetes 就是来解决这个问题的! Kubernetes 提供了一个框架来弹性运行分布式系统。 该框架负责扩展需求,故障转移,部署模式等。 例如,Kubernetes 可以轻松管理系统的 Canary 部署。
|
||||
|
||||
Kubernetes 为用户提供了:
|
||||
1\. 服务发现和负载平衡
|
||||
2\. 存储编排
|
||||
3\. 自动退出和回退
|
||||
4\. 自动打包
|
||||
5\. 自我修复
|
||||
6\. 秘密配置管理
|
||||
|
||||
**Kubernetes 可以做什么?**
|
||||
|
||||
在本文中,我们将会看到一些从头构建 Web 应用程序时如何使用 Kubernetes 的代码示例。我们将在 Python 中使用 Flask 创建一个简单的后端服务器。
|
||||
对于那些想从头开始构建 Web 应用程序的人,有一些前提条件,即:
|
||||
|
||||
1\. 对 Docker,Docker 容器和 Docker 映像的基本了解。可以访问该网站
|
||||
_<https://www.docker.com/sites/default/files/Docker\_CheatSheet\_08.09.2016\_0.pdf>_快速了解。
|
||||
2\. 系统中应该安装Docker。
|
||||
3\. 系统中应该安装Kubernetes,有关如何在本地计算机上安装的说明,请访问网站 _<https://kubernetes.io/docs/setup/learning-environment/minikube/>_.
|
||||
|
||||
现在,创建一个目录,如下代码片段所示:
|
||||
```
|
||||
mkdir flask-kubernetes/app && cd flask-kubernetes/app
|
||||
```
|
||||
|
||||
接下来,在 _flask-kubernetes/app_ 目录中,创建一个名为 main.py 的文件,如下面的代码片段所示:
|
||||
```
|
||||
touch main.py
|
||||
```
|
||||
|
||||
在新创建的 _main.py,_ 文件中,粘贴下面代码:
|
||||
|
||||
```
|
||||
from flask import Flask
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route("/")
|
||||
def hello():
|
||||
return "Hello from Kubernetes!"
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host='0.0.0.0')
|
||||
```
|
||||
|
||||
使用下面命令在本地安装 Flask:
|
||||
|
||||
```
|
||||
pip install Flask==0.10.1
|
||||
```
|
||||
|
||||
Flask 安装后,执行下面的命令:
|
||||
```
|
||||
python app.py
|
||||
```
|
||||
|
||||
|
||||
应该在本地运行Flask服务器,Flask应用程序的默认端口是5000,并且你可以在 *<http://localhost:500*0> 上看到输出‘Hello from Kubernetes!’。 一旦服务器在本地运行,我们就创建一个供 Kubernetes 使用的 Docker 映像。 创建一个名为 Dockerfile 的文件,并将以下代码片段粘贴到其中:
|
||||
|
||||
|
||||
```
|
||||
FROM python:3.7
|
||||
|
||||
RUN mkdir /app
|
||||
WORKDIR /app
|
||||
ADD . /app/
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
EXPOSE 5000
|
||||
CMD ["python", "/app/main.py"]
|
||||
```
|
||||
|
||||
_Dockerfile_文件的说明如下:
|
||||
|
||||
1\. Docker 将从 Docker 集线器获取 Python 3.7 映像。
|
||||
2\. 将在映像中创建一个应用程序目录。
|
||||
3\. 它将一个应用程序设置为工作目录。
|
||||
4\. 将内容从主机中的应用程序目录复制到映像应用程序目录。
|
||||
5\. 暴露端口5000。
|
||||
6\. 最后,它运行命令,启动 Flask 服务器。
|
||||
接下来,我们将使用以下命令创建 Docker 映像:
|
||||
|
||||
```
|
||||
docker build -f Dockerfile -t flask-kubernetes:latest .
|
||||
```
|
||||
|
||||
创建Docker映像后,我们可以使用以下命令在本地运行该映像进行测试:
|
||||
|
||||
```
|
||||
docker run -p 5001:5000 flask-kubernetes
|
||||
```
|
||||
|
||||
通过运行容器在本地完成测试之后,我们需要在 Kubernetes 中部署它。 我们将首先使用 kubectl 命令验证 Kubernetes 是否正在运行。 如果没有报错,则说明它正在工作。 如果有报错,请参考该网站信息: _<https://kubernetes.io/docs/setup/learning-environment/minikube/>_.
|
||||
|
||||
接下来, 我们创建一个部署文件。 这是一个Yaml文件,其中包含有关 Kubernetes 的说明,该说明涉及如何以声明性的方式创建 pod 和服务。 因为我们有 Flask Web 应用程序,我们将在其中包含 pod 和 services 声明的情况下创建一个deployment.yaml文件。
|
||||
创建一个名为 deployment.yaml 的文件并向其中添加以下内容,然后保存:
|
||||
|
||||
```
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: flask-kubernetes -service
|
||||
spec:
|
||||
selector:
|
||||
app: flask-kubernetes
|
||||
ports:
|
||||
- protocol: "TCP"
|
||||
port: 6000
|
||||
targetPort: 5000
|
||||
type: LoadBalancer
|
||||
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: flask-kubernetes
|
||||
spec:
|
||||
replicas: 4
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: flask-kubernetes
|
||||
spec:
|
||||
containers:
|
||||
- name: flask-kubernetes
|
||||
image: flask-kubernetes:latest
|
||||
imagePullPolicy: Never
|
||||
ports:
|
||||
- containerPort: 5000
|
||||
```
|
||||
|
||||
使用以下命令将 yaml 文件发送到 Kubernete:
|
||||
|
||||
```
|
||||
kubectl apply -f deployment.yaml
|
||||
```
|
||||
|
||||
如果执行以下命令,你会看到 pods 正在运行:
|
||||
|
||||
```
|
||||
kubectl get pods
|
||||
```
|
||||
|
||||
|
||||
现在,导航至_<http://localhost:6000>_,你应该会看到‘Hello from Kubernetes!’消息。 成功了! 该应用程序现在正在 Kubernetes 中运行!
|
||||
|
||||
**Kubernetes 做不了什么 **
|
||||
Kubernetes 不是一个传统的,包罗万象的 PaaS(平台即服务)系统。 由于 Kubernetes 运行在容器级别而非硬件级别,因此它提供了 PaaS 产品共有的一些普遍适用功能,如部署,扩展,负载平衡,日志记录和监控。 Kubernetes 为开发人员平台提供了构建块,但在重要的地方保留了用户的选择和灵活性。
|
||||
|
||||
* Kubernetes 不限制所支持的应用程序的类型。 如果应用程序可以在容器中运行,那么它应该可以在 Kubernetes 上更好地运行。
|
||||
* 它不部署和构建源代码。
|
||||
* 它不决定日志记录,监视或警报解决方案。
|
||||
* 它不提供或不要求配置语言/系统。 它提供了一个声明的API供所有人使用。
|
||||
* 它不提供或不采用任何全面的机器配置,维护,管理或自我修复系统。
|
||||
|
||||
|
||||
![Avatar][3]
|
||||
|
||||
[Abhinav Nath Gupta][4]
|
||||
|
||||
本文作者 Abhinav 是班加罗尔 Cleo 软件公司的一名软件开发工程师。他对密码学、数据安全、虚拟货币及云计算方面很感兴趣,可以通过 [abhi.aec89@gmail.com][5] 与他联系。.
|
||||
|
||||
[![][6]][7]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensourceforu.com/2019/11/demystifying-kubernetes/
|
||||
|
||||
作者:[Abhinav Nath Gupta][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[Morisun029](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensourceforu.com/author/abhinav-gupta/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Gear-kubernetes.jpg?resize=696%2C457&ssl=1 (Gear kubernetes)
|
||||
[2]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Gear-kubernetes.jpg?fit=800%2C525&ssl=1
|
||||
[3]: https://secure.gravatar.com/avatar/f65917facf5f28936663731fedf545c4?s=100&r=g
|
||||
[4]: https://opensourceforu.com/author/abhinav-gupta/
|
||||
[5]: mailto:abhi.aec89@gmail.com
|
||||
[6]: http://opensourceforu.com/wp-content/uploads/2013/10/assoc.png
|
||||
[7]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US
|
Loading…
Reference in New Issue
Block a user