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
0c47c371c3
@ -0,0 +1,60 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Data-center power consumption holds steady)
|
||||
[#]: via: (https://www.networkworld.com/article/3531316/data-center-power-consumption-holds-steady.html)
|
||||
[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/)
|
||||
|
||||
Data-center power consumption holds steady
|
||||
======
|
||||
While computing capacity has exploded in recent years, power consumption is growing more slowly thanks to greater energy efficiency.
|
||||
Google
|
||||
|
||||
A predicted explosion in power consumption by data centers has not manifested thanks to advances in power efficiency and, ironically enough, the move to the cloud, according to a new report.
|
||||
|
||||
The [study][1], published in the journal _Science_ last week, notes that while there has been an increase in global data-center energy consumption over the past decade, this growth is negligible compared with the rise of workloads and deployed hardware during that time.
|
||||
|
||||
Data centers accounted for about 205 terawatt-hours of electricity usage in 2018, which is roughly 1% of all electricity consumption worldwide, according to the report. (That's well below the often-cited stat that data centers consume 2% of the world's electricity). The 205 terawatt-hours represent a 6% increase in total power consumption since 2010, but global data center compute instances rose by 550% over that same time period.
|
||||
|
||||
**[ Now read: [What is quantum computing (and why enterprises should care)][2] ]**
|
||||
|
||||
To drive that point home: Considerably more compute is being deployed, yet the amount of power consumed is holding steady.
|
||||
|
||||
The paper cites a number of reasons for this. For starters, hardware power efficiency is vastly improved. The move to server virtualization has meant a six-fold increase in compute instances with only a 25% increase in server energy use. And a shift to faster and more energy-efficient port technologies has brought about a 10-fold increase in data center IP traffic with only a modest increase in the energy use of network devices.
|
||||
|
||||
Even more interesting, the report claims the rise of and migration to hyperscalers has helped curtail power consumption.
|
||||
|
||||
Hyperscale data centers and cloud data centers are generally more energy efficient than company-owned data centers because there is greater incentive for energy efficiency. The less power Amazon, Microsoft, Google, etc., have to buy, the more their bottom line grows. And hyperscalers are big on cheap, renewable energy, such as hydro and wind.
|
||||
|
||||
[][3]
|
||||
|
||||
So if a company trades its own old, inefficient data center for AWS or Google Cloud, they're reducing the overall power draw of data centers as a whole.
|
||||
|
||||
"Total power consumption held steady as computing output has risen because of improvement efficiency of both IT and infrastructure equipment, and a shift from corporate data centers to more efficient cloud data centers (especially hyper scale)," said Jonathan Koomey, a Stanford professor and one of the authors of the research, in an email to me. He has spent years researching data center power and is an authority on the subject.
|
||||
|
||||
"As always, the IT equipment progresses most quickly. In this article, we show that the peak output efficiency of computing doubled every 2.6 years after 2000. This doesn’t include the reduced idle power factored into the changes for servers we document," he added.
|
||||
|
||||
Koomey notes that there is additional room for efficiency improvements to cover the next doubling of computing output over the next few years but was reluctant to make projections out too far. "We avoid projecting the future of IT because it changes so fast, and we are skeptical of those who think they can project IT electricity use 10-15 years hence," he said.
|
||||
|
||||
Join the Network World communities on [Facebook][4] and [LinkedIn][5] to comment on topics that are top of mind.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3531316/data-center-power-consumption-holds-steady.html
|
||||
|
||||
作者:[Andy Patrizio][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/Andy-Patrizio/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://science.sciencemag.org/content/367/6481/984
|
||||
[2]: https://www.networkworld.com/article/3275367/what-s-quantum-computing-and-why-enterprises-need-to-care.html
|
||||
[3]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage)
|
||||
[4]: https://www.facebook.com/NetworkWorld/
|
||||
[5]: https://www.linkedin.com/company/network-world
|
@ -0,0 +1,61 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Setting yourself up for success while working remotely)
|
||||
[#]: via: (https://opensource.com/article/20/3/remote-work)
|
||||
[#]: author: (Dawn Parzych https://opensource.com/users/dawnparzych)
|
||||
|
||||
Setting yourself up for success while working remotely
|
||||
======
|
||||
Whether you are new to working remotely or are a seasoned veteran, here
|
||||
are tips to improve the experience.
|
||||
![Woman sitting in front of her computer][1]
|
||||
|
||||
Remote work is not easy. While there are perks to being remote, it is a mind-shift and takes some getting used to. Talk to anybody that works remotely, and they will likely tell you some of the biggest challenges of remote work are _**feeling disconnected**_ and _**a loss of regime**_. Here are my tips gathered from 10 years as a remote worker on how to set yourself and your team up to work remotely successfully.
|
||||
|
||||
### Environment and regime
|
||||
|
||||
1. **"Commute" to and from work**. I'm not saying go to the extremes in this [_Audible commercial_][2], but I suggest leaving your home to go for a walk or a bike ride before you begin working. Do the same at the end of the day. I take my dog, Barley (pictured here), for a walk at the start and end of most days.![Here's my dog, Barley, who gets regular walks during my morning "commute"][3]
|
||||
2. **Get dressed.** Don't be tempted to work in your PJs, because this blurs the line between work and home. People sometimes say that being able to work in your pajamas is a perk of remote work, but studies show this isn't great advice. You don't need to put on a suit and tie, but do change out of your pajamas; otherwise, before you know it, you will have gone three days without changing your clothes. For more reasons why check out this article from [_Fast Company_][4].
|
||||
3. **Eat lunch away from your desk**. This is good advice even if you aren't working remotely.
|
||||
4. **Stick to a schedule**. It's easy to start working as soon as you wake up and continue late into the evening. Set a start time and an end time for your day and stick to it. When I stop work for the day, I try to close my office door. Configure your working hours in every app you use so others know when you are available. Don't use your work computer outside of working hours if you can.
|
||||
5. **Set up a dedicated work environment**, if possible. Try not to work from the kitchen table. This blurs the lines between home and work. My office (picture below) also has space for comfortable seating and desk seating to switch between the two.
|
||||
6. **Check-in with your team** or friends in the morning. Don't mistake this for a daily stand-up; this is more like saying _hi_ when you're getting coffee.
|
||||
7. **Sign-off at the end of the day**. This means both letting your team members know you are leaving and actually walking away from where you are working. Close the laptop. Turn off Slack notifications, etc.
|
||||
8. **Keep people posted** if you are leaving early or unavailable. It helps build trust.
|
||||
9. **Invest in a headset** if you will be doing a lot of calls. If there is more than one person in your household that is working remotely, they will thank you for this. It is no fun listening to somebody else's conference call.
|
||||
10. **Turn on your video** when on a video call to help you feel connected and stay engaged. When your video is disabled, it is easy to wander off and get distracted by Slack (or its [open source alternatives][5]), Twitter, or any other number of distractions.
|
||||
11. **Set up a weekly, casual remote chat**. At my company, we meet on Friday mornings via Zoom (or the open source alternative, [Jitsi][6]). This chat is open to remote and non-remote staff. It is an open call to talk about whatever is on our minds. Topics have ranged from music preferences to parenting challenges to what people are doing over the weekend.
|
||||
12. **Set-up chat-roulette **if one-on-one interaction is more your thing. There are applications on most chat platforms that randomly pairs two employees to chat and get to know one another.
|
||||
13. **Ask for help**. Chat with your colleagues if you're stuck, need encouragement, or need to vent. You are not alone. You are a member of a team. You can still grab a coffee or go for a walk with a teammate remotely.
|
||||
|
||||
|
||||
|
||||
![Here’s my home office set up][7]
|
||||
|
||||
Everybody is different. These tips work for me, I’d love to hear you share your advice below!
|
||||
|
||||
Not all work-from-home gigs are created equal. There is a vast ocean between being a member of a...
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/3/remote-work
|
||||
|
||||
作者:[Dawn Parzych][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/dawnparzych
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_women_computing_2.png?itok=JPlR5aCA (Woman sitting in front of her computer)
|
||||
[2]: https://www.youtube.com/watch?v=oVCJhZhrJ04
|
||||
[3]: https://opensource.com/sites/default/files/resize/pictures/barleywalking_0-300x379.png (Here's my dog, Barley, who gets regular walks during my morning "commute")
|
||||
[4]: https://www.fastcompany.com/3064295/what-happened-when-i-dressed-up-to-work-from-home-for-a-week
|
||||
[5]: https://opensource.com/alternatives/slack
|
||||
[6]: https://meet.jit.si/
|
||||
[7]: https://opensource.com/sites/default/files/pictures/6151f75e-bbeb-4e64-a5ca-0bbe4e981054.jpeg (Here’s my home office set up)
|
@ -1,211 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Basic kubectl and Helm commands for beginners)
|
||||
[#]: via: (https://opensource.com/article/20/2/kubectl-helm-commands)
|
||||
[#]: author: (Jessica Cherry https://opensource.com/users/jrepka)
|
||||
|
||||
Basic kubectl and Helm commands for beginners
|
||||
======
|
||||
Take a trip to the grocery store to shop for the commands you'll need to
|
||||
get started with these Kubernetes tools.
|
||||
![A person working.][1]
|
||||
|
||||
Recently, my husband was telling me about an upcoming job interview where he would have to run through some basic commands on a computer. He was anxious about the interview, but the best way for him to learn and remember things has always been to equate the thing he doesn't know to something very familiar to him. Because our conversation happened right after I was roaming the grocery store trying to decide what to cook that evening, it inspired me to write about kubectl and Helm commands by equating them to an ordinary trip to the grocer.
|
||||
|
||||
[Helm][2] is a tool to manage applications within Kubernetes. You can easily deploy charts with your application information, allowing them to be up and preconfigured in minutes within your Kubernetes environment. When you're learning something new, it's always helpful to look at chart examples to see how they are used, so if you have time, take a look at these stable [charts][3].
|
||||
|
||||
[Kubectl][4] is a command line that interfaces with Kubernetes environments, allowing you to configure and manage your cluster. It does require some configuration to work within environments, so take a look through the [documentation][5] to see what you need to do.
|
||||
|
||||
I'll use namespaces in the examples, which you can learn about in my article [_Kubernetes namespaces for beginners_][6].
|
||||
|
||||
Now that we have that settled, let's start shopping for basic kubectl and Helm commands!
|
||||
|
||||
### Helm list
|
||||
|
||||
What is the first thing you do before you go to the store? Well, if you're organized, you make a **list**. LIkewise, this is the first basic Helm command I will explain.
|
||||
|
||||
In a Helm-deployed application, **list** provides details about an application's current release. In this example, I have one deployed application—the Jenkins CI/CD application. Running the basic **list** command always brings up the default namespace. Since I don't have anything deployed in the default namespace, nothing shows up:
|
||||
|
||||
|
||||
```
|
||||
$helm list
|
||||
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
|
||||
```
|
||||
|
||||
However, if I run the command with an extra flag, my application and information appear:
|
||||
|
||||
|
||||
```
|
||||
$helm list --all-namespaces
|
||||
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
|
||||
jenkins jenkins 1 2020-01-18 16:18:07 EST deployed jenkins-1.9.4 lts
|
||||
```
|
||||
|
||||
Finally, I can direct the **list** command to check only the namespace I want information from:
|
||||
|
||||
|
||||
```
|
||||
$helm list --namespace jenkins
|
||||
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
|
||||
jenkins jenkins 1 2020-01-18 16:18:07 EST deployed jenkins-1.9.4 lts
|
||||
```
|
||||
|
||||
Now that I have a list and know what is on it, I can go and get my items with **get** commands! I'll start with the Kubernetes cluster; what can I get from it?
|
||||
|
||||
### Kubectl get
|
||||
|
||||
The **kubectl get** command gives information about many things in Kubernetes, including pods, nodes, and namespaces. Again, without a namespace flag, you'll always land in the default. First, I'll get the namespaces in the cluster to see what's running:
|
||||
|
||||
|
||||
```
|
||||
$kubectl get namespaces
|
||||
NAME STATUS AGE
|
||||
default Active 53m
|
||||
jenkins Active 44m
|
||||
kube-node-lease Active 53m
|
||||
kube-public Active 53m
|
||||
kube-system Active 53m
|
||||
```
|
||||
|
||||
Now that I have the namespaces running in my environment, I'll get the nodes and see how many are running:
|
||||
|
||||
|
||||
```
|
||||
$kubectl get nodes
|
||||
NAME STATUS ROLES AGE VERSION
|
||||
minikube Ready master 55m v1.16.2
|
||||
```
|
||||
|
||||
I have one node up and running, mainly because my Minikube is running on one small server. To get the pods running on my one node:
|
||||
|
||||
|
||||
```
|
||||
$kubectl get pods
|
||||
No resources found in default namespace.
|
||||
```
|
||||
|
||||
Oops, it's empty. I'll get what's in my Jenkins namespace with:
|
||||
|
||||
|
||||
```
|
||||
$kubectl get pods --namespace jenkins
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
jenkins-7fc688c874-mh7gv 1/1 Running 0 40m
|
||||
```
|
||||
|
||||
Good news! There's one pod, it hasn't restarted, and it has been running for 40 minutes. Well, since I know the pod is up, I want to see what I can get from Helm.
|
||||
|
||||
### Helm get
|
||||
|
||||
**Helm get** is a little more complicated because this **get** command requires more than an application name, and you can request multiple things from applications. I'll begin by getting the values used to make the application, and then I'll show a snip of the **get all** action, which provides all the data related to the application.
|
||||
|
||||
|
||||
```
|
||||
$helm get values jenkins -n jenkins
|
||||
USER-SUPPLIED VALUES:
|
||||
null
|
||||
```
|
||||
|
||||
Since I did a very minimal stable-only install, the configuration didn't change. If I run the **all** command, I get everything out of the chart:
|
||||
|
||||
|
||||
```
|
||||
`$helm get all jenkins -n jenkins`
|
||||
```
|
||||
|
||||
![output from helm get all command][7]
|
||||
|
||||
This produces a ton of data, so I always recommend keeping a copy of a Helm chart so you can look over the templates in the chart. I also create my own values to see what I have in place.
|
||||
|
||||
Now that I have all my goodies in my shopping cart, I'll check the labels that **describe** what's in them. These examples pertain only to kubectl, and they describe what I've deployed through Helm.
|
||||
|
||||
### Kubectl describe
|
||||
|
||||
As I did with the **get** command, which can describe just about anything in Kubernetes, I'll limit my examples to namespaces, pods, and nodes. Since I know I'm working with one of each, this will be easy.
|
||||
|
||||
|
||||
```
|
||||
$kubectl describe ns jenkins
|
||||
Name: jenkins
|
||||
Labels: <none>
|
||||
Annotations: <none>
|
||||
Status: Active
|
||||
No resource quota.
|
||||
No resource limits.
|
||||
```
|
||||
|
||||
I can see my namespace's name and that it is active and has no resource nor quote limits.
|
||||
|
||||
The **describe pods** command produces a large amount of information, so I'll provide a small snip of the output. If you run the command without the pod name, it will return information for all of the pods in the namespace, which can be overwhelming. So, be sure you always include the pod name with this command. For example:
|
||||
|
||||
|
||||
```
|
||||
`$kubectl describe pods jenkins-7fc688c874-mh7gv --namespace jenkins`
|
||||
```
|
||||
|
||||
![output of kubectl-describe-pods][8]
|
||||
|
||||
This provides (among many other things) the status of the container, how the container is managed, the label, and the image used in the pod. The data not in this abbreviated output includes resource requests and limits along with any conditions, init containers, and storage volume information applied in a Helm values file. This data is useful if your application is crashing due to inadequate resources, a configured init container that runs a prescript for configuration, or generated hidden passwords that shouldn't be in a plain text YAML file.
|
||||
|
||||
Finally, I'll use **describe node**, which (of course) describes the node. Since this example has just one, named Minikube, that is what I'll use; if you have multiple nodes in your environment, you must include the node name of interest.
|
||||
|
||||
As with pods, the node command produces an abundance of data, so I'll include just a snip of the output.
|
||||
|
||||
|
||||
```
|
||||
`$kubectl describe node minikube`
|
||||
```
|
||||
|
||||
![output of kubectl describe node][9]
|
||||
|
||||
Note that **describe node** is one of the more important basic commands. As this image shows, the command returns statistics that indicate when the node is running out of resources, and this data is excellent for alerting you when you need to scale up (if you do not have autoscaling in your environment). Other things not in this snippet of output include the percentages of requests made for all resources and limits, as well as the age and allocation of resources (e.g., for my application).
|
||||
|
||||
### Checking out
|
||||
|
||||
With these commands, I've finished my shopping and gotten everything I was looking for. Hopefully, these basic commands can help you, too, in your day-to-day with Kubernetes.
|
||||
|
||||
I urge you to work with the command line often and learn the shorthand flags available in the Help sections, which you can access by running these commands:
|
||||
|
||||
|
||||
```
|
||||
`$helm --help`
|
||||
```
|
||||
|
||||
and
|
||||
|
||||
|
||||
```
|
||||
`$kubectl -h`
|
||||
```
|
||||
|
||||
### Peanut butter and jelly
|
||||
|
||||
Some things just go together like peanut butter and jelly. Helm and kubectl are a little like that.
|
||||
|
||||
I often use these tools in my environment. Because they have many similarities in a ton of places, after using one, I usually need to follow up with the other. For example, I can do a Helm deployment and watch it fail using kubectl. Try them together, and see what they can do for you.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/2/kubectl-helm-commands
|
||||
|
||||
作者:[Jessica Cherry][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/jrepka
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003784_02_os.comcareers_os_rh2x.png?itok=jbRfXinl (A person working.)
|
||||
[2]: https://helm.sh/
|
||||
[3]: https://github.com/helm/charts/tree/master/stable
|
||||
[4]: https://kubernetes.io/docs/reference/kubectl/kubectl/
|
||||
[5]: https://kubernetes.io/docs/reference/kubectl/overview/
|
||||
[6]: https://opensource.com/article/19/12/kubernetes-namespaces
|
||||
[7]: https://opensource.com/sites/default/files/uploads/helm-get-all.png (output from helm get all command)
|
||||
[8]: https://opensource.com/sites/default/files/uploads/kubectl-describe-pods.png (output of kubectl-describe-pods)
|
||||
[9]: https://opensource.com/sites/default/files/uploads/kubectl-describe-node.png (output of kubectl describe node)
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -0,0 +1,394 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Directing Kubernetes traffic with Traefik)
|
||||
[#]: via: (https://opensource.com/article/20/3/kubernetes-traefik)
|
||||
[#]: author: (Lee Carpenter https://opensource.com/users/carpie)
|
||||
|
||||
Directing Kubernetes traffic with Traefik
|
||||
======
|
||||
A step-by-step walkthrough on ingressing traffic into a
|
||||
Kubernetes-Raspberry Pi cluster.
|
||||
![Digital creative of a browser on the internet][1]
|
||||
|
||||
In this article, we will deploy a couple of simple websites and learn how to ingress traffic from the outside world into our cluster using Traefik. After that, we will learn how to remove Kubernetes resources as well. Let’s get started!
|
||||
|
||||
### Materials needed
|
||||
|
||||
To follow along with the article, you only need [the k3s Raspberry Pi cluster][2] we built in a previous article. Since your cluster will be pulling images from the web, the cluster will need to be able to access the internet.
|
||||
|
||||
Some configuration files and sample HTML files will be shown in this article for explanation purposes. All sample files can be downloaded [here][3].
|
||||
|
||||
### Deploying a simple website
|
||||
|
||||
Previously, we did a direct deploy with **kubectl**. This is not the typical way to deploy things, however. Generally, YAML configuration files are used, and that is what we will use in this article. We will start at the top and create our configuration files in a top-down approach.
|
||||
|
||||
### Deployment configuration
|
||||
|
||||
First up is the deployment configuration. The configuration is shown below, and the explanation follows. I typically use the samples from the [Kubernetes documentation][4] as a starting point and then modify them to suit my needs. For example, the configuration below was modified after copying the sample from the [deployment docs][5].
|
||||
|
||||
Create a file, **mysite.yaml**, with the following contents:
|
||||
|
||||
|
||||
```
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: mysite-nginx
|
||||
labels:
|
||||
app: mysite-nginx
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: mysite-nginx
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: mysite-nginx
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx
|
||||
ports:
|
||||
- containerPort: 80
|
||||
```
|
||||
|
||||
Most of this is boilerplate. The important parts, we have named our deployment **mysite-nginx** with an **app** label of **mysite-nginx **as well. We have specified that we want one **replica** which means there will only be one pod created. We also specified **one container**, which we named **nginx**. We specified the **image** to be **nginx**. This means, on deployment, k3s will download the **nginx** image from DockerHub and create a pod from it. Finally, we specified a **containerPort** of **80**, which just means that inside the container the pod will listen on port **80**.
|
||||
|
||||
I emphasized "inside the container" above because it is an important distinction. As we have the container configured, it is only accessible inside the container, and it is further restricted to an internal network. This is necessary to allow multiple containers to listen on the same container ports. In other words, with this configuration, some other pod could listen on its container port 80 as well and not conflict with this one. To provide formal access to this pod, we need a **service** configuration.
|
||||
|
||||
### Service configuration
|
||||
|
||||
In Kubernetes, a **service** is an abstraction. It provides a means to access a pod or set of pods. One connects to the service and the service routes to a single pod or load balances to multiple pods if multiple pod replicas are defined.
|
||||
|
||||
The service can be specified in the same configuration file, and that is what we will do here. Separate configuration areas with **`---`**. Add the following to **mysite.yaml**:
|
||||
|
||||
|
||||
```
|
||||
\---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: mysite-nginx-service
|
||||
spec:
|
||||
selector:
|
||||
app: mysite-nginx
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80
|
||||
```
|
||||
|
||||
In this configuration, we have named our service **mysite-nginx-service**. We provided a `selector` of **app: mysite-nginx**. This is how the service chooses the application containers it routes to. Remember, we provided an **app** label for our container as **mysite-nginx**. This is what the service will use to find our container. Finally, we specified that the service protocol is **TCP** and the service listens on port **80**.
|
||||
|
||||
### Ingress configuration
|
||||
|
||||
The ingress configuration specifies how to get traffic from outside our cluster to services inside our cluster. Remember, k3s comes pre-configured with Traefik as an ingress controller. Therefore, we will write our ingress configuration specific to Traefik. Add the following to **mysite.yaml **( and don’t forget to separate with **`---`**):
|
||||
|
||||
|
||||
```
|
||||
\---
|
||||
apiVersion: networking.k8s.io/v1beta1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: mysite-nginx-ingress
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: "traefik"
|
||||
spec:
|
||||
rules:
|
||||
- http:
|
||||
paths:
|
||||
- path: /
|
||||
backend:
|
||||
serviceName: mysite-nginx-service
|
||||
servicePort: 80
|
||||
```
|
||||
|
||||
In this configuration, we have named the ingress record **mysite-nginx-ingress**. And we told Kubernetes that we expect **traefik** to be our ingress controller with the **kubernetes.io/ingress.class** annotation.
|
||||
|
||||
In the **rules** section, we are basically saying, when **http** traffic comes in, and the **path** matches **`/`** (or anything below that), route it to the **backend** service specified by the **serviceName mysite-nginx-service**, and route it to **servicePort 80**. This connects incoming HTTP traffic to the service we defined earlier.
|
||||
|
||||
### Something to deploy
|
||||
|
||||
That is really it as far as configuration goes. If we deployed now, we would get the default **nginx** page, but that is not what we want. Let’s create something simple but custom to deploy. Create the file **index.html** with the following contents:
|
||||
|
||||
|
||||
```
|
||||
<html>
|
||||
<head><title>K3S!</title>
|
||||
<style>
|
||||
html {
|
||||
font-size: 62.5%;
|
||||
}
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
background-color: midnightblue;
|
||||
color: white;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
height: 100vh;
|
||||
}
|
||||
div {
|
||||
text-align: center;
|
||||
font-size: 8rem;
|
||||
text-shadow: 3px 3px 4px dimgrey;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>Hello from K3S!</div>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
We have not yet covered storage mechanisms in Kubernetes, so we are going to cheat a bit and just store this file in a Kubernetes config map. This is not the recommended way to deploy a website, but it will work for our purposes. Run the following:
|
||||
|
||||
|
||||
```
|
||||
`kubectl create configmap mysite-html --from-file index.html`
|
||||
```
|
||||
|
||||
This command creates a `configmap` resource named **mysite-html** from the local file **index.html**. This essentially stores a file (or set of files) inside a Kubernetes resource that we can call out in configuration. It is typically used to store configuration files (hence the name), so we are abusing it a bit here. In a later article, we will discuss proper storage solutions in Kubernetes.
|
||||
|
||||
With the config map created, let’s mount it inside our **nginx** container. We do this in two steps. First, we need to specify a **volume**, calling out the config map. Then we need to mount the volume into the **nginx** container. Complete the first step by adding the following under the **spec** label, just after **containers** in **mysite.yaml**:
|
||||
|
||||
|
||||
```
|
||||
volumes:
|
||||
- name: html-volume
|
||||
configMap:
|
||||
name: mysite-html
|
||||
```
|
||||
|
||||
This tells Kubernetes that we want to define a **volume**, with the name **html-volume** and that volume should contain the contents of the **configMap** named **html-volume** (which we created in the previous step).
|
||||
|
||||
Next, in the **nginx** container specification, just under **ports**, add the following:
|
||||
|
||||
|
||||
```
|
||||
volumeMounts:
|
||||
- name: html-volume
|
||||
mountPath: /usr/share/nginx/html
|
||||
```
|
||||
|
||||
This tells Kubernetes, for the **nginx** container, we want to mount a **volume** named **html-volume** at the path (in the container) **/usr/share/nginx/html**. Why **/usr/share/nginx/html**? That is where the **nginx** image serves HTML from. By mounting our volume at that path, we have replaced the default contents with our volume contents.
|
||||
|
||||
For reference, the **deployment** section of the configuration file should now look like this:
|
||||
|
||||
|
||||
```
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: mysite-nginx
|
||||
labels:
|
||||
app: mysite-nginx
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: mysite-nginx
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: mysite-nginx
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx
|
||||
ports:
|
||||
- containerPort: 80
|
||||
volumeMounts:
|
||||
- name: html-volume
|
||||
mountPath: /usr/share/nginx/html
|
||||
volumes:
|
||||
- name: html-volume
|
||||
configMap:
|
||||
name: mysite-html
|
||||
```
|
||||
|
||||
### Deploy it!
|
||||
|
||||
Now we are ready to deploy! We can do that with:
|
||||
|
||||
|
||||
```
|
||||
`kubectl apply -f mysite.yaml`
|
||||
```
|
||||
|
||||
You should see something similar to the following:
|
||||
|
||||
|
||||
```
|
||||
deployment.apps/mysite-nginx created
|
||||
service/mysite-nginx-service created
|
||||
ingress.networking.k8s.io/mysite-nginx-ingress created
|
||||
```
|
||||
|
||||
This means that Kubernetes created resources for each of the three configurations we specified. Check on the status of the pods with:
|
||||
|
||||
|
||||
```
|
||||
`kubectl get pods`
|
||||
```
|
||||
|
||||
If you see a status of **ContainerCreating**, give it some time and run **kubectl get pods** again. Typically, the first time, it will take a while because k3s has to download the **nginx** image to create the pod. After a while, you should get a status of **Running**.
|
||||
|
||||
### Try it!
|
||||
|
||||
Once the pod is running, it is time to try it. Open up a browser and type **kmaster** into the address bar.
|
||||
|
||||
![][6]
|
||||
|
||||
Congratulations! You’ve deployed a website on your k3s cluster!
|
||||
|
||||
### Another one
|
||||
|
||||
So now we have a whole k3s cluster running a single website. But we can do more! What if we have another website we want to serve on the same cluster? Let’s see how to do that.
|
||||
|
||||
Again, we need something to deploy. It just so happens that my dog has a message she has wanted the world to know for some time. So, I crafted some HTML just for her (available from the samples zip file). Again, we will use the config map trick to host our HTML. This time we are going to poke a whole directory (the **html** directory) into a config map, but the invocation is the same.
|
||||
|
||||
|
||||
```
|
||||
`kubectl create configmap mydog-html --from-file html`
|
||||
```
|
||||
|
||||
Now we need to create a configuration file for this site. It is almost exactly the same as the one for **mysite.yaml**, so start by copying **mysite.yaml** to **mydog.yaml**. Now edit **mydog.yaml** to be:
|
||||
|
||||
|
||||
```
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: mydog-nginx
|
||||
labels:
|
||||
app: mydog-nginx
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: mydog-nginx
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: mydog-nginx
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx
|
||||
ports:
|
||||
- containerPort: 80
|
||||
volumeMounts:
|
||||
- name: html-volume
|
||||
mountPath: /usr/share/nginx/html
|
||||
volumes:
|
||||
- name: html-volume
|
||||
configMap:
|
||||
name: mydog-html
|
||||
\---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: mydog-nginx-service
|
||||
spec:
|
||||
selector:
|
||||
app: mydog-nginx
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80
|
||||
\---
|
||||
apiVersion: networking.k8s.io/v1beta1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: mydog-nginx-ingress
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: "traefik"
|
||||
traefik.frontend.rule.type: PathPrefixStrip
|
||||
spec:
|
||||
rules:
|
||||
- http:
|
||||
paths:
|
||||
- path: /mydog
|
||||
backend:
|
||||
serviceName: mydog-nginx-service
|
||||
servicePort: 80
|
||||
```
|
||||
|
||||
We can do most of the edits by simply doing a search and replace of **mysite** to **mydog**. The two other edits are in the ingress section. We changed **path** to **/mydog **and we added an annotation, **traefik.frontend.rule.type: PathPrefixStrip**.
|
||||
|
||||
The specification of the path **/mydog** instructs Traefik to route any incoming request that requests a path starting with **/mydog** to the **mydog-nginx-service**. Any other path will continue to be routed to **mysite-nginx-service.**
|
||||
|
||||
The new annotation, **PathPrefixStrip**, tells Traefik to strip off the prefix **/mydog** before sending the request to **mydog-nginx-service**. We did this because the **mydog-nginx** application doesn’t expect a prefix. This means we could change where the service was mounted simply by changing the prefix in the ingress record.
|
||||
|
||||
Now we can deploy like we did before:
|
||||
|
||||
|
||||
```
|
||||
`kubectl apply -f mydog.yaml`
|
||||
```
|
||||
|
||||
And now, my dog’s message should be available at <http://kmaster/mydog/>.
|
||||
|
||||
![][7]
|
||||
|
||||
Phew! The message is out! Maybe we can all get some sleep tonight.
|
||||
|
||||
So now, we have a k3s cluster hosting two websites with Traefik making decisions, based on path names, as to which service to pass the request to! We are not limited to path-based routing, however. We could use hostname based routing as well, which we will explore in a future article.
|
||||
|
||||
Also, the websites we just hosted are standard unencrypted HTML sites. Everything these days is encrypted with SSL/TLS. In our next article, we will add support to our k3s cluster to host SSL/TLS HTTPS sites as well!
|
||||
|
||||
### Cleaning up
|
||||
|
||||
Before you go, since this article mostly dealt with sample sites, I would like to show you how to delete things in case you don’t want the samples hanging around on your cluster.
|
||||
|
||||
For most configurations, you can undo the configuration simply by running the **delete** command with the same configuration file you deployed with. So let’s clean up both **mysite** and **mydog**.
|
||||
|
||||
|
||||
```
|
||||
kubectl delete -f mysite.yaml
|
||||
kubectl delete -f mydog.yaml
|
||||
```
|
||||
|
||||
Since we manually created the config maps, we’ll need to delete those manually as well.
|
||||
|
||||
|
||||
```
|
||||
kubectl delete configmap mysite-html
|
||||
kubectl delete configmap mydog-html
|
||||
```
|
||||
|
||||
Now if we do a **kubectl get pods**, we should see that our nginx pods are no longer around.
|
||||
|
||||
|
||||
```
|
||||
$ kubectl get pods
|
||||
No resources found in default namespace.
|
||||
```
|
||||
|
||||
Everything is cleaned up.
|
||||
|
||||
Tell me what thoughts you have on this project in the comments below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/3/kubernetes-traefik
|
||||
|
||||
作者:[Lee Carpenter][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/carpie
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_web_internet_website.png?itok=g5B_Bw62 (Digital creative of a browser on the internet)
|
||||
[2]: https://opensource.com/article/20/3/kubernetes-raspberry-pi
|
||||
[3]: https://gitlab.com/carpie/ingressing_with_k3s/-/archive/master/ingressing_with_k3s-master.zip
|
||||
[4]: https://kubernetes.io/docs/
|
||||
[5]: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#creating-a-deployment
|
||||
[6]: https://opensource.com/sites/default/files/uploads/mysite.jpg
|
||||
[7]: https://opensource.com/sites/default/files/uploads/mydog.jpg
|
@ -0,0 +1,155 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to install pip to manage PyPI packages easily)
|
||||
[#]: via: (https://opensource.com/article/20/3/pip-linux-mac-windows)
|
||||
[#]: author: (Vijay Singh Khatri https://opensource.com/users/vijaytechnicalauthor)
|
||||
|
||||
How to install pip to manage PyPI packages easily
|
||||
======
|
||||
Install the pip package manager on older versions of Python on Linux,
|
||||
Mac, and Windows that don't come preinstalled with pip.
|
||||
![Person typing on a 1980's computer][1]
|
||||
|
||||
Python is a powerful and popular programming language with many packages that are useful for general programming, data science, and many other things. These packages are not included with the Python installation, so you have to download, install, and manage them separately. All of these packages (libraries and frameworks) are stored in a central repository called the Python Package Index, or [PyPI][2] for short. This is where pip (short for Preferred Installer Program), Python's package manager, comes into the picture.
|
||||
|
||||
Installing Python pip on your system allows you to manage PyPI packages easily. Many of these packages can be installed just by typing **python -m pip install <package-name>** into a terminal or command-line.
|
||||
|
||||
Newer versions of Python 3 (3.4 and higher) and Python 2 (2.7.9 and higher) come preloaded with pip. Older versions of Python didn't include pip, but it can be installed retroactively.
|
||||
|
||||
In this article, I explain how to install pip on Linux, Mac, and Windows computers. You can also check the [pip.pypa][3] documentation for more information.
|
||||
|
||||
### Make sure Python is installed
|
||||
|
||||
If you don't already have Python installed on your system, do that first; otherwise, the pip installer won't understand any commands. To check whether you have Python, enter **python** in your command line, Bash, or terminal window and see what happens. If the command is not recognized, then you need to [download Python][4]. If you have Python installed, you will see a lot of commands and other stuff that will indicate you can install pip.
|
||||
|
||||
### Install Python pip on Linux
|
||||
|
||||
The command you use to install pip on Linux depends on the distribution you use.
|
||||
|
||||
On Fedora, RHEL, and CentOS:
|
||||
|
||||
|
||||
```
|
||||
`$ sudo dnf install python3`
|
||||
```
|
||||
|
||||
For Debian or Ubuntu, use the Apt package:
|
||||
|
||||
|
||||
```
|
||||
`$ sudo apt install python3-pip`
|
||||
```
|
||||
|
||||
Other distributions may have their own package manager. For example, Arch Linux uses pacman:
|
||||
|
||||
|
||||
```
|
||||
`$ sudo pacman -S python-pip`
|
||||
```
|
||||
|
||||
To find out whether pip is installed properly, check the version using the **\--version** option.
|
||||
|
||||
That's all you need. You can skip down to the [using pip][5] section of this article.
|
||||
|
||||
### Install Python pip on Mac
|
||||
|
||||
MacOS comes with Python installed by default, but the version provided by Apple is almost always outdated, even right an OS release. If you're working with Python, you should [use a custom install of Python 3][6].
|
||||
|
||||
To install Python 3 on a Mac, use [homebrew][7]:
|
||||
|
||||
|
||||
```
|
||||
`$ brew update && brew upgrade python`
|
||||
```
|
||||
|
||||
Because you've installed a recent version of Python3, pip is also installed. ****You can verify it with:
|
||||
|
||||
|
||||
```
|
||||
`$ python3 -m pip --version`
|
||||
```
|
||||
|
||||
That's all you need. You can skip down to the [using pip][5] section of this article.
|
||||
|
||||
### Install Python pip on Windows
|
||||
|
||||
To install pip, you must have Windows 8 or 10. The screenshots below are from Windows 10 (but the same commands work for Windows 8).
|
||||
|
||||
Once you confirm you have [Python installed][8].
|
||||
|
||||
If you want the same luxuries as Linux users have with a package manager, you can use the [Chocolatey][9] package manager for Windows. This provides easy access to Python but also easy updates. You can use it in the open source PowerShell application to make amazing things happen in just a few commands.
|
||||
|
||||
|
||||
```
|
||||
`PS> choco install python`
|
||||
```
|
||||
|
||||
That's it! You can now use pip to install any package you need.
|
||||
|
||||
### Using Python pip
|
||||
|
||||
Python pip works exactly the same way on each platform: Linux, BSD, Windows, Mac, and so on.
|
||||
|
||||
To install the imaginary library **foo**, use:
|
||||
|
||||
|
||||
```
|
||||
`python3 -m pip install foo --user`
|
||||
```
|
||||
|
||||
To uninstall it:
|
||||
|
||||
|
||||
```
|
||||
`python3 -m pip uninstall foo`
|
||||
```
|
||||
|
||||
To search for a package:
|
||||
|
||||
|
||||
```
|
||||
`python3 -m pip search foo`
|
||||
```
|
||||
|
||||
To upgrade to a new version of pip:
|
||||
|
||||
|
||||
```
|
||||
`$ sudo pip install --upgrade pip`
|
||||
```
|
||||
|
||||
On Windows, omit the **sudo** command (Windows has its own method of privilege management, so you may need to [create an exception to your execution policy][10]).
|
||||
|
||||
|
||||
```
|
||||
`python -m pip install --upgrade pip`
|
||||
```
|
||||
|
||||
I hope you tried the installation methods described in this article and that they helped you. Please share your experience in the comments.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/3/pip-linux-mac-windows
|
||||
|
||||
作者:[Vijay Singh Khatri][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/vijaytechnicalauthor
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/1980s-computer-yearbook.png?itok=eGOYEKK- (Person typing on a 1980's computer)
|
||||
[2]: https://pypi.org/
|
||||
[3]: https://pip.pypa.io/en/stable/installing/
|
||||
[4]: https://www.python.org/downloads/
|
||||
[5]: tmp.u1JOYd3gs9#usage
|
||||
[6]: https://opensource.com/article/19/5/python-3-default-mac
|
||||
[7]: https://brew.sh
|
||||
[8]: https://opensource.com/article/19/8/how-install-python-windows
|
||||
[9]: https://opensource.com/article/20/3/chocolatey
|
||||
[10]: https://opensource.com/article/20/3/chocolatey#admin
|
@ -0,0 +1,209 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Using the Quarkus Framework on Fedora Silverblue – Just a Quick Look)
|
||||
[#]: via: (https://fedoramagazine.org/using-the-quarkus-framework-on-fedora-silverblue-just-a-quick-look/)
|
||||
[#]: author: (Stephen Snow https://fedoramagazine.org/author/jakfrost/)
|
||||
|
||||
Using the Quarkus Framework on Fedora Silverblue – Just a Quick Look
|
||||
======
|
||||
|
||||
![Using the Quarkus Framework on Fedora Silverblue – Just a Quick Look][1]
|
||||
|
||||
[Quarkus][2] is a framework for Java development that is described on their web site as:
|
||||
|
||||
> A Kubernetes Native Java stack tailored for OpenJDK HotSpot and GraalVM, crafted from the best of breed Java libraries and standards
|
||||
>
|
||||
> <https://quarkus.io/> – Feb. 5, 2020
|
||||
|
||||
Silverblue — a Fedora Workstation variant with a container based workflow central to its functionality — should be an ideal host system for the Quarkus framework.
|
||||
|
||||
There are currently two ways to use Quarkus with Silverblue. It can be run in a pet container such as Toolbox/Coretoolbox. Or it can be run directly in a terminal emulator. This article will focus on the latter method.
|
||||
|
||||
### Why Quarkus
|
||||
|
||||
[According to Quarkus.io][3]: “Quarkus has been designed around a containers first philosophy. What this means in real terms is that Quarkus is optimized for low memory usage and fast startup times.” To achieve this, they employ first class support for Graal/Substrate VM, build time Metadata processing, reduction in reflection usage, and native image preboot. For details about why this matters, read [Container First][3] at Quarkus.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
A few prerequisites will need to configured before you can start using Quarkus. First, you need an IDE of your choice. Any of the popular ones will do. VIM or Emacs will work as well. The Quarkus site provides full details on how to set up the three major Java IDE’s (Eclipse, Intellij Idea, and Apache Netbeans). You will need a version of JDK installed. JDK 8, JDK 11 or any distribution of OpenJDK is fine. GrallVM 19.2.1 or 19.3.1 is needed for compiling down to native. You will also need Apache Maven 3.53+ or Gradle. This article will use Maven because that is what the author is more familiar with. Use the following command to layer Java 11 OpenJDK and Maven onto Silverblue:
|
||||
|
||||
```
|
||||
$ rpm-ostree install java-11-openjdk* maven
|
||||
```
|
||||
|
||||
Alternatively, you can download your favorite version of Java and install it directly in your home directory.
|
||||
|
||||
After rebooting, configure your _JAVA_HOME_ and _PATH_ environment variables to reference the new applications. Next, go to the [GraalVM download page][4], and get GraalVM version 19.2.1 or version 19.3.1 for Java 11 OpenJDK. Install Graal as per the instructions provided. Basically, copy and decompress the archive into a directory under your home directory, then modify the _PATH_ environment variable to include Graal. You use it as you would any JDK. So you can set it up as a platform in the IDE of your choice. Now is the time to setup the native image if you are going to use one. For more details on setting up your system to use Quarkus and the Quarkus native image, check out their [Getting Started tutorial][5]. With these parts installed and the environment setup, you can now try out Quarkus.
|
||||
|
||||
### Bootstrapping
|
||||
|
||||
Quarkus recommends you create a project using the bootstrapping method. Below are some example commands entered into a terminal emulator in the Gnome shell on Silverblue.
|
||||
|
||||
```
|
||||
$ mvn io.quarkus:quarkus-maven-plugin:1.2.1.Final:create \
|
||||
-DprojectGroupId=org.jakfrost \
|
||||
-DprojectArtifactId=silverblue-logo \
|
||||
-DclassName="org.jakfrost.quickstart.GreetingResource" \
|
||||
-Dpath="/hello"
|
||||
$ cd silverblue-logo
|
||||
```
|
||||
|
||||
The bootstrapping process shown above will create a project under the current directory with the name _silverblue-logo_. After this completes, start the application in development mode:
|
||||
|
||||
```
|
||||
$ ./mvnw compile quarkus:dev
|
||||
```
|
||||
|
||||
With the application running, check whether it responds as expected by issuing the following command:
|
||||
|
||||
```
|
||||
$ curl -w '\n' http://localhost:8080/hello
|
||||
```
|
||||
|
||||
The above command should print _hello_ on the next line. Alternatively, test the application by browsing to _<http://localhost:8080/hello>_ with your web browser. You should see the same lonely _hello_ on an otherwise empty page. Leave the application running for the next section.
|
||||
|
||||
### Injection
|
||||
|
||||
Open the project in your favorite IDE. If you are using Netbeans, simply open the project directory where the _pom.xml_ file resides. Now would be a good time to have a look at the _pom.xml_ file.
|
||||
|
||||
Quarkus uses ArC for its dependency injection. ArC is a dependency of quarkus-resteasy, so it is already part of the core Quarkus installation. Add a companion bean to the project by creating a java class in your IDE called _GreetingService.java_. Then put the following code into it:
|
||||
|
||||
```
|
||||
import javax.enterprise.context.ApplicationScoped;
|
||||
|
||||
@ApplicationScoped
|
||||
public class GreetingService {
|
||||
|
||||
public String greeting(String name) {
|
||||
return "hello " + name;
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
The above code is a verbatim copy of what is used in the injection example in the Quarkus Getting Started tutorial. Modify _GreetingResource.java_ by adding the following lines of code:
|
||||
|
||||
```
|
||||
import javax.inject.Inject;
|
||||
import org.jboss.resteasy.annotations.jaxrs.PathParam;
|
||||
|
||||
@Inject
|
||||
GreetingService service;//inject the service
|
||||
|
||||
@GET //add a getter to use the injected service
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
@Path("/greeting/{name}")
|
||||
public String greeting(@PathParam String name) {
|
||||
return service.greeting(name);
|
||||
}
|
||||
```
|
||||
|
||||
If you haven’t stopped the application, it will be easy to see the effect of your changes. Just enter the following _curl_ command:
|
||||
|
||||
```
|
||||
$ curl -w '\n' http://localhost:8080/hello/greeting/Silverblue
|
||||
```
|
||||
|
||||
The above command should print _hello Silverblue_ on the following line. The URL should work similarly in a web browser. There are two important things to note:
|
||||
|
||||
1. The application was running and Quarkus detected the file changes on the fly.
|
||||
2. The injection of code into the app was very easy to perform.
|
||||
|
||||
|
||||
|
||||
### The native image
|
||||
|
||||
Next, package your application as a native image that will work in a _podman_ container. Exit the application by pressing **CTRL-C**. Then use the following command to package it:
|
||||
|
||||
```
|
||||
$ ./mvnw package -Pnative -Dquarkus.native.container-runtime=podman
|
||||
```
|
||||
|
||||
Now, build the container:
|
||||
|
||||
```
|
||||
$ podman build -f src/main/docker/Dockerfile.native -t silverblue-logo/silverblue-logo
|
||||
```
|
||||
|
||||
Now run it with the following:
|
||||
|
||||
```
|
||||
$ podman run -i --rm -p 8080:8080 localhost/silverblue-logo/silverblue-logo
|
||||
```
|
||||
|
||||
To get the container build to successfully complete, it was necessary to copy the _/target_ directory and contents into the _src/main/docker/_ directory. Investigation as to the reason why is still required, and though the solution used was quick and easy, it is not an acceptable way to solve the problem.
|
||||
|
||||
Now that you have the container running with the application inside, you can use the same methods as before to verify that it is working.
|
||||
|
||||
Point your browser to the URL <http://localhost:8080/> and you should get a _index.html_ that is automatically generated by Quarkus every time you create or modify an application. It resides in the _src/main/resources/META-INF/resources/_ directory. Drop other HTML files in this _resources_ directory to have Quarkus serve them on request.
|
||||
|
||||
For example, create a file named _logo.html_ in the _resources_ directory containing the below markup:
|
||||
|
||||
```
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
To change this license header, choose License Headers in Project Properties.
|
||||
To change this template file, choose Tools | Templates
|
||||
and open the template in the editor.
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>Silverblue</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<img src="fedora-silverblue-logo.png" alt="Fedora Silverblue"/>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
Next, save the below image alongside the _logo.html_ file with the name _fedora-silverblue-logo.png_:
|
||||
|
||||
![][6]
|
||||
|
||||
Now view the results at <http://localhost:8080/logo.html>.
|
||||
|
||||
#### Testing your application
|
||||
|
||||
Quarkus supports junit 5 tests. Look at your project’s _pom.xml_ file. In it you should see two test dependencies. The generated project will contain a simple test, named _GreetingResourceTest.java_. Testing for the native file is only supported in _prod_ mode. However, you can test the _jar_ file in _dev_ mode. These tests are RestAssured, but you can use whatever test library you wish with Quarkus. Use Maven to run the tests:
|
||||
|
||||
```
|
||||
$ ./mvnw test
|
||||
```
|
||||
|
||||
More details can be found in the Quarkus [Getting Started][7] tutorial.
|
||||
|
||||
#### Further reading and tutorials
|
||||
|
||||
Quarkus has an extensive collection of [tutorials and guides][8]. They are well worth the time to delve into the breadth of this microservices framework.
|
||||
|
||||
Quarkus also maintains a [publications][9] page that lists some very interesting articles on actual use cases of Quarkus. This article has only just scratched the surface of the topic. If what was presented here has piqued your interest, then follow the above links for more information.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/using-the-quarkus-framework-on-fedora-silverblue-just-a-quick-look/
|
||||
|
||||
作者:[Stephen Snow][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://fedoramagazine.org/author/jakfrost/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://fedoramagazine.org/wp-content/uploads/2020/02/quarkus-816x345.jpg
|
||||
[2]: https://quarkus.io/
|
||||
[3]: https://quarkus.io/vision/container-first
|
||||
[4]: https://www.graalvm.org/downloads/
|
||||
[5]: https://quarkus.io/get-started/
|
||||
[6]: https://fedoramagazine.org/wp-content/uploads/2020/02/fedora-silverblue-logo.png
|
||||
[7]: https://quarkus.io/guides/getting-started
|
||||
[8]: https://quarkus.io/guides/
|
||||
[9]: https://quarkus.io/publications/
|
@ -0,0 +1,243 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (What you need to know about variables in Emacs)
|
||||
[#]: via: (https://opensource.com/article/20/3/variables-emacs)
|
||||
[#]: author: (Clemens Radermacher https://opensource.com/users/clemera)
|
||||
|
||||
What you need to know about variables in Emacs
|
||||
======
|
||||
Learn how Elisp deals with variables and to use them in your scripts and
|
||||
configurations.
|
||||
![Programming keyboard.][1]
|
||||
|
||||
GNU Emacs is written in C and Emacs Lisp (Elisp), a dialect of the Lisp programming language. Because it's a text editor that happens to be an Elisp sandbox, it is helpful to understand how basic programming concepts work in Elisp.
|
||||
|
||||
If you're new to [Emacs][2], visit Sacha Chua's excellent list of [resources for Emacs beginners][3]. This article assumes you're familiar with common Emacs terminology and that you know how to read and evaluate basic snippets of Elisp code. Ideally, you should also have heard of variable scope and how it works in another programming language. The examples also assume you use a fairly recent Emacs version ([v.25 or later][4]).
|
||||
|
||||
The [Elisp manual][5] includes everything there is to know, but it is written for people who already know what they are looking for (and it is really great for that). But many people want resources that explain Elisp concepts at a higher level and reduce the amount of information to the most useful bits. This article is my attempt to respond to that—to give readers a good grasp of the basics so they can use them for their configuration and make it easier for people to look up some detail in the manual.
|
||||
|
||||
### Global variables
|
||||
|
||||
User options defined with **defcustom** and variables defined with **defvar** or **defconst** are global. One important aspect of variables declared by **defcustom** or **defvar** is that reevaluating them won't reset a variable if it is already bound. For example, if you establish a binding for **my-var** in your init file like this:
|
||||
|
||||
|
||||
```
|
||||
`(setq my-var nil)`
|
||||
```
|
||||
|
||||
evaluating the following form won't reset the variable to **t**:
|
||||
|
||||
|
||||
```
|
||||
`(defvar my-var t)`
|
||||
```
|
||||
|
||||
Note that there is _one exception_: If you evaluate the declaration above with **C-M-x** that calls **eval-defun**, the value will be reset to **t**. This way, you can enforce setting the value if you need to. This behavior is intentional: As you might know, many features in Emacs load only on demand (i.e., they are autoloaded). If the declarations in those files reset variables to their default value, this would override any settings in your init.
|
||||
|
||||
### User options
|
||||
|
||||
A user option is simply a global variable that is declared with **defcustom**. Unlike variables declared with **defvar**, such a variable is configurable with the **M-x customize** interface. As far as I know, most people don't use it much because it feels clunky. Once you know how to set variables in your init file, there's no compelling reason to use it. One detail many users aren't aware of is that setting user options with **customize** might execute code, and this is sometimes used to run additional setup instructions:
|
||||
|
||||
|
||||
```
|
||||
(defcustom my-option t
|
||||
"My user option."
|
||||
:set (lambda (sym val)
|
||||
(set-default sym val)
|
||||
(message "Set %s to %s" sym val)))
|
||||
```
|
||||
|
||||
If you evaluate this code and change the value using the **customize** interface with **M-x customize-option RET my-option RET **the lambda will be called, and the message in the echo area will tell you the symbol and value of the option.
|
||||
|
||||
If you use **setq** in your init file, to change the value of such an option, the setter function will _not_ run. To set such an option correctly with Elisp, you need to use the function **customize-set-variable**. Alternatively, people use various versions of **csetq** macros in their configs to automatically take care of this (you can use GitHub code search to discover more sophisticated variants if you like):
|
||||
|
||||
|
||||
```
|
||||
(defmacro csetq (sym val)
|
||||
`(funcall (or (get ',sym 'custom-set) 'set-default) ',sym ,val))
|
||||
```
|
||||
|
||||
If you are using the [use-package][6] macro, the **:custom** keyword will handle this for you.
|
||||
|
||||
After putting the code above into your init file, you can use **csetq** to set variables in a way that respects any existing setter functions. You can prove this by watching the message in the echo area when using this macro to change the option defined above:
|
||||
|
||||
|
||||
```
|
||||
`(csetq my-option nil)`
|
||||
```
|
||||
|
||||
### Dynamic binding and lexical binding
|
||||
|
||||
If you use other programming languages, you may not be aware of the differences between dynamic and lexical binding. Most programming languages today use lexical binding, and there is no need to know the difference when you learn about variable scope/lookup.
|
||||
|
||||
Emacs Lisp is special in this regard because dynamic binding is the default, and lexical binding must be enabled explicitly. There are historical reasons for this, and in practice, you should _always_ enable lexical binding because it is faster and less error-prone. To enable it, simply put the following comment line as the first line in your Emacs Lisp file:
|
||||
|
||||
|
||||
```
|
||||
`;;; -*- lexical-binding: t; -*-`
|
||||
```
|
||||
|
||||
Alternatively, you can call M-x **add-file-local-variable-prop-line**, which will insert the comment line above when you choose the variable **lexical-binding** with value **t**.
|
||||
|
||||
When a file with such a specially formatted line is loaded, Emacs sets the variable accordingly, which means the code in that buffer is loaded with lexical binding enabled. Interactively, you can use **M-x eval-buffer**, which takes the lexical binding setting into account.
|
||||
|
||||
Now that you know how to enable lexical binding, it's smart to learn what the terms mean. With dynamic binding, the last binding established during program execution is used for variable lookup. You can test this by putting the following code in an empty buffer and executing **M-x eval-buffer**:
|
||||
|
||||
|
||||
```
|
||||
(defun a-exists-only-in-my-body (a)
|
||||
(other-function))
|
||||
|
||||
(defun other-function ()
|
||||
(message "I see `a', its value is %s" a))
|
||||
|
||||
(a-exists-only-in-my-body t)
|
||||
```
|
||||
|
||||
You may be surprised to see that the lookup of variable **a** in the **other-function** is successful.
|
||||
|
||||
If you retry the preceding example with the special lexical-binding comment at the top, the code will throw a "variable is void" error because **other-function** does not know about the **a** variable. If you're coming from another programming language, this is the behavior you would expect.
|
||||
|
||||
With lexical binding, the scope is defined by the surrounding source code. This is not only for performance reasons—experience and time have shown that this behavior is preferred.
|
||||
|
||||
### Special variables and dynamic binding
|
||||
|
||||
As you may know, **let** is used to temporary establish local bindings:
|
||||
|
||||
|
||||
```
|
||||
(let ((a "I'm a")
|
||||
(b "I'm b"))
|
||||
(message "Hello, %s. Hello %s" a b))
|
||||
```
|
||||
|
||||
Here is the thing: Variables declared with **defcustom**, **defvar**, or **defconst** are called _special variables_, and they continue to use dynamic binding regardless of whether lexical binding is enabled:
|
||||
|
||||
|
||||
```
|
||||
;;; -*- lexical-binding: t; -*-
|
||||
|
||||
(defun some-other-function ()
|
||||
(message "I see `c', its value is: %s" c))
|
||||
|
||||
(defvar c t)
|
||||
|
||||
(let ((a "I'm lexically bound")
|
||||
(c "I'm special and therefore dynamically bound"))
|
||||
(some-other-function)
|
||||
(message "I see `a', its values is: %s" a))
|
||||
```
|
||||
|
||||
To see both messages in the example above, switch to the ***Messages*** buffer using **C-h e**.
|
||||
|
||||
Local variables bound with **let** or function arguments follow the lookup rules defined by the **lexical-binding** variable, but global variables defined with **defvar**, **defconst**, or **defcustom** can be changed deep down in the call stack for the duration of the **let** body.
|
||||
|
||||
This behavior allows for convenient ad-hoc customizations and is often used in Emacs, which isn't surprising given that Emacs Lisp started out with dynamic binding being the only option. Here is a common example showing how you can temporarily write to a read-only buffer:
|
||||
|
||||
|
||||
```
|
||||
(let ((inhibit-read-only t))
|
||||
(insert ...))
|
||||
```
|
||||
|
||||
Here is another often-seen example for performing case-sensitive searches:
|
||||
|
||||
|
||||
```
|
||||
(let ((case-fold-search nil))
|
||||
(some-function-which-uses-search ...))
|
||||
```
|
||||
|
||||
Dynamic binding allows you to change the behavior of functions in ways the authors of those functions may have never anticipated. It's a powerful tool and a great feature for a program that is designed and used like Emacs.
|
||||
|
||||
There is one caveat to be aware of: You might accidentally use a local variable name that is declared as a special variable elsewhere. One trick to prevent such conflicts is to avoid dashes in local variables' names. In my current Emacs session, this leaves only a handful of potential conflicting candidates:
|
||||
|
||||
|
||||
```
|
||||
(let ((vars ()))
|
||||
(mapatoms
|
||||
(lambda (cand)
|
||||
(when (and (boundp cand)
|
||||
(not (keywordp cand))
|
||||
(special-variable-p cand)
|
||||
(not (string-match "-"
|
||||
(symbol-name cand))))
|
||||
(push cand vars))))
|
||||
vars) ;; => (t obarray noninteractive debugger nil)
|
||||
```
|
||||
|
||||
### Buffer-local variables
|
||||
|
||||
Each buffer can have a local binding for a variable. This means any variable lookup made while this buffer is current will reveal the buffer's local value of that variable instead of the default value. Local variables are an important feature in Emacs; for example, they are used by major modes to establish their buffer-local behavior and settings.
|
||||
|
||||
You have already seen a buffer-local variable in this article: the special comment line for **lexical-binding** that binds the buffer locally to **t**. In Emacs, such buffer-local variables defined in special comment lines are also called _file-local variables_.
|
||||
|
||||
Any global variable can be shadowed by a buffer-local variable. Take, for example, the **my-var** variable defined above, which you can set locally like this:
|
||||
|
||||
|
||||
```
|
||||
(setq-local my-var t)
|
||||
;; or (set (make-local-variable 'my-var) t)
|
||||
```
|
||||
|
||||
**my-var** is local to the buffer, which is current when you evaluate the code above. If you call **describe-variable** on it, the documentation tells you both the local value and the global one. Programmatically, you can check the local value using **buffer-local-value** and the default value with **default-value**. To remove the local version, you could invoke **M-x kill-local-variable**.
|
||||
|
||||
Another important property to be aware of is that once a variable is buffer-local, any further use of **setq** (while this buffer is current) will continue to set the local value. To set the default value, you would need to use **setq-default**.
|
||||
|
||||
Because local variables are meant for buffer customization, they're used most often in mode hooks. A typical example would be something like this:
|
||||
|
||||
|
||||
```
|
||||
(add-hook 'go-mode-hook
|
||||
(defun go-setup+ ()
|
||||
(setq-local compile-command
|
||||
(if (string-suffix-p "_test.go" buffer-file-name)
|
||||
"go test -v"
|
||||
(format "go run %s"
|
||||
(shell-quote-argument
|
||||
(file-name-nondirectory buffer-file-name)))))))
|
||||
```
|
||||
|
||||
This sets the compile command used by **M-x compile** for go-mode buffers.
|
||||
|
||||
Another important aspect is that some variables are _automatically_ buffer-local. This means as soon as you **setq** such a variable, it sets a local binding for the current buffer. This feature shouldn't be used often (because this implicit behavior isn't nice), but if you want, you can create such automatically local variables like this:
|
||||
|
||||
|
||||
```
|
||||
(defvar-local my-automatical-local-var t)
|
||||
;; or (make-variable-buffer-local 'my-automatical-local-var)
|
||||
```
|
||||
|
||||
The variable **indent-tabs-mode** is a built-in example of this. If you use **setq** in your init file to change the value of this variable, it won't affect the default value at all. Only the value for the buffer that is current while loading your init file will be changed. Therefore, you need to use **setq-default** to change the default value of **indent-tabs-mode**.
|
||||
|
||||
### Closing words
|
||||
|
||||
Emacs is a powerful editor, and it only gets more powerful the more you change it to suit your needs. Now you know how Elisp deals with variables and how you can use them in your own scripts and configurations.
|
||||
|
||||
* * *
|
||||
|
||||
_This previously appeared on [With-Emacs][7] under a CC BY-NC-SA 4.0 license and has been adapted (with a merge request) and republished with the author's permission._
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/3/variables-emacs
|
||||
|
||||
作者:[Clemens Radermacher][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/clemera
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming_keyboard_coding.png?itok=E0Vvam7A (Programming keyboard.)
|
||||
[2]: https://www.gnu.org/software/emacs/
|
||||
[3]: http://sachachua.com/blog/p/27144
|
||||
[4]: https://www.gnu.org/software/emacs/download.html
|
||||
[5]: https://www.gnu.org/software/emacs/manual/html_node/elisp/
|
||||
[6]: https://github.com/jwiegley/use-package#customizing-variables
|
||||
[7]: https://with-emacs.com/posts/tutorials/almost-all-you-need-to-know-about-variables/
|
@ -0,0 +1,87 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Amazon Has Launched Its Own Linux Distribution But It’s Not for Everyone)
|
||||
[#]: via: (https://itsfoss.com/bottlerocket-linux/)
|
||||
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
|
||||
|
||||
Amazon Has Launched Its Own Linux Distribution But It’s Not for Everyone
|
||||
======
|
||||
|
||||
Amazon has [launched][1] its own Linux-based open source operating system, Bottlerocket.
|
||||
|
||||
Before you get too excited and try to install and run it, I must tell you that it’s not your regular Linux distribution like Ubuntu, Fedora or Debian. What is it then?
|
||||
|
||||
### Bottlerocket: Linux distribution from Amazon for running containers
|
||||
|
||||
![][2]
|
||||
|
||||
If you are not aware of containers in Linux, I recommend reading [this article][3] from Red Hat.
|
||||
|
||||
A lot has changed in the IT industry since the term cloud computing was first coined. It takes few seconds to deploy a Linux server (usually running in a VM) thanks to cloud server providers like Amazon AWS, Google, [Linode][4], Digital Ocean etc. On top of that, you can deploy applications and services on these servers in form of containers thanks to tools like Docker and Kubernetes.
|
||||
|
||||
The thing is that when your sole purpose is to run containers on a Linux system, a full-fledged Linux distribution is not always required. This is why there are container specific Linux that provide only the necessary packages. This reduces the size of the operating system drastically which further reduces the deployment time.
|
||||
|
||||
**[Bottlerocket][5] Linux is purpose-built by Amazon Web Services for running containers on virtual machines or bare metal hosts.** It supports docker images and other images that follow the [OCI image][6] format.
|
||||
|
||||
### Features of Bottlerocket Linux
|
||||
|
||||
![][7]
|
||||
|
||||
Here’s what this new Linux distribution from Amazon offers:
|
||||
|
||||
#### No package-by-package updates
|
||||
|
||||
The traditional Linux distribution update procedure is composed of updating individual packages. Bottlerocket uses image-based updates instead.
|
||||
|
||||
Thanks to this approach, conflicts and breakage are avoided with the possibility of a rapid and complete rollback (if necessary).
|
||||
|
||||
#### Read-only file system
|
||||
|
||||
Bottlerocket also uses a primarily read-only file system. Its integrity is checked at boot time via dm-verity. For additional security measures, SSH access is also discouraged and is only available through the [admin container][8] (additional mechanism).
|
||||
|
||||
AWS already rules the cloud world and with it
|
||||
|
||||
#### Automated updates
|
||||
|
||||
You can automate updates to Bottlerocket by using an orchestration service like Amazon EKS.
|
||||
|
||||
Amazon also claims that including only the essential software to run containers reduces the attack surface compared to general purpose Linux distributions.
|
||||
|
||||
### What do you think?
|
||||
|
||||
Amazon is not the first to create a ‘container specific Linux’. I think CoreOS was among the first such distributions. [CoreOS was acquired by Red Hat][9] which itself was [sold to IBM][10]. Red Hat recently discontinued CoreOS and replaced it with [Fedora CoreOS][11].
|
||||
|
||||
Cloud server is a big industry that will continue to grow bigger. A giant like Amazon will do everything to stay at par or ahead with its competitors. In my opinion, Bottlerocket is an answer to (now) IBM’s Fedora CoreOS.
|
||||
|
||||
Though [Bottlerocket repositories are available on GitHub][12], I could not find any ready to image yet. At the moment of writing this article, it is only [available as a preview on AWS][5].
|
||||
|
||||
What are your views on it? What does Amazon gain with Bottlerocket? If you used something like CoreOS before, will you switch to Bottlerocket?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/bottlerocket-linux/
|
||||
|
||||
作者:[Abhishek Prakash][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/abhishek/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://aws.amazon.com/blogs/aws/bottlerocket-open-source-os-for-container-hosting/
|
||||
[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/botlerocket-logo.png?ssl=1
|
||||
[3]: https://www.redhat.com/en/topics/containers/whats-a-linux-container
|
||||
[4]: https://www.linode.com/
|
||||
[5]: https://aws.amazon.com/bottlerocket/
|
||||
[6]: https://www.opencontainers.org/
|
||||
[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/BottleRocket.png?ssl=1
|
||||
[8]: https://github.com/bottlerocket-os/bottlerocket-admin-container
|
||||
[9]: https://itsfoss.com/red-hat-acquires-coreos/
|
||||
[10]: https://itsfoss.com/ibm-red-hat-acquisition/
|
||||
[11]: https://getfedora.org/en/coreos/
|
||||
[12]: https://github.com/bottlerocket-os/bottlerocket
|
@ -7,69 +7,69 @@
|
||||
[#]: via: (https://fedoramagazine.org/how-to-setup-a-dns-server-with-bind/)
|
||||
[#]: author: (Curt Warfield https://fedoramagazine.org/author/rcurtiswarfield/)
|
||||
|
||||
How to setup a DNS server with bind
|
||||
如何使用 bind 设置 DNS 服务器
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
The Domain Name System, or DNS, as it’s more commonly known, translates or converts domain names into the IP addresses associated with that domain. DNS is the reason you are able to find your favorite website by name instead of typing an IP address into your browser. This guide shows you how to configure a Master DNS system and one client.
|
||||
域名系统或 DNS(通常称为 DNS)将域名翻译或转换为与该域关联的 IP 地址。DNS 是能够让你通过名称找到自己喜欢的网站而不是在浏览器中输入 IP 地址的原因。本指南将向你展示如何配置一个主 DNS 系统以及客户端。
|
||||
|
||||
Here are system details for the example used in this article:
|
||||
以下是本文示例中使用的系统细节:
|
||||
|
||||
```
|
||||
dns01.fedora.local (192.168.1.160 ) - Master DNS server
|
||||
client.fedora.local (192.168.1.136 ) - Client
|
||||
dns01.fedora.local (192.168.1.160)- 主 DNS 服务器
|
||||
client.fedora.local (192.168.1.136)- 客户端
|
||||
```
|
||||
|
||||
### DNS server configuration
|
||||
### DNS 服务器配置
|
||||
|
||||
Install the bind packages using sudo:
|
||||
使用 sudo 安装 bind 包:
|
||||
|
||||
```
|
||||
$ sudo dnf install bind bind-utils -y
|
||||
```
|
||||
|
||||
The _/etc/named.conf_ configuration file is provided by the _bind_ package to allow you to configure the DNS server.
|
||||
_bind_ 包提供了_/etc/named.conf_ 配置文件,来供你配置 DNS 服务器。
|
||||
|
||||
Edit the _/etc/named.conf_ file:
|
||||
编辑 _/etc/named.conf_ 文件:
|
||||
|
||||
```
|
||||
sudo vi /etc/named.conf
|
||||
```
|
||||
|
||||
Look for the following line:
|
||||
查找以下行:
|
||||
|
||||
```
|
||||
listen-on port 53 { 127.0.0.1; };
|
||||
```
|
||||
|
||||
Add the IP address of your Master DNS server as follows:
|
||||
添加主 DNS 服务器的 IP 地址,如下所示:
|
||||
|
||||
```
|
||||
listen-on port 53 { 127.0.0.1; 192.168.1.160; };
|
||||
```
|
||||
|
||||
Look for the next line:
|
||||
查找以下行:
|
||||
|
||||
```
|
||||
allow-query { localhost; };
|
||||
```
|
||||
|
||||
Add your local network range. The example system uses IP addresses in the 192.168.1.X range. This is specified as follows:
|
||||
添加本地网络范围。该示例系统使用的 IP 地址在 192.168.1.X 的范围内。指定如下:
|
||||
|
||||
```
|
||||
allow-query { localhost; 192.168.1.0/24; };
|
||||
```
|
||||
|
||||
Specify a forward and reverse zone. Zone files are simply text files that have the DNS information, such as IP addresses and host-names, on your system. The forward zone file makes it possible for the translation of a host-name to its IP address. The reverse zone file does the opposite. It allows a remote system to translate an IP address to the host name.
|
||||
指定转发和反向区域。区域文件只是具有系统上 DNS 信息(例如 IP 地址和主机名)的文本文件。转发区域文件使得将主机名转换为 IP 地址成为可能。反向区域文件则相反。它允许远程系统将 IP 地址转换为主机名。
|
||||
|
||||
Look for the following line at the bottom of the /etc/named.conf file:
|
||||
在 /etc/named.conf 文件的底部查找以下行:
|
||||
|
||||
```
|
||||
include "/etc/named.rfc1912.zones";
|
||||
```
|
||||
|
||||
Here, you’ll specify the zone file information _**directly above that line**_ as follows:
|
||||
在此处,你将在_**该行的正上方**_指定区域文件信息,如下所示:
|
||||
|
||||
```
|
||||
zone "dns01.fedora.local" IN {
|
||||
@ -85,19 +85,19 @@ allow-update { none; };
|
||||
};
|
||||
```
|
||||
|
||||
The _forward.fedora.local_ and the file _reverse.fedora.local_ are just the names of the zone files you will be creating. They can be called anything you like.
|
||||
_forward.fedora.local_ 和 _reverse.fedora.local_ 文件是要创建的区域文件的名称。它们可以是任意名字。
|
||||
|
||||
Save and exit.
|
||||
保存并退出。
|
||||
|
||||
#### Create the zone files
|
||||
#### 创建区域文件
|
||||
|
||||
Create the forward and reverse zone files you specified in the /etc/named.conf file:
|
||||
创建你在 /etc/named.conf 文件中指定的转发和反向区域文件:
|
||||
|
||||
```
|
||||
$ sudo vi /var/named/forward.fedora.local
|
||||
```
|
||||
|
||||
Add the following lines:
|
||||
添加以下行:
|
||||
|
||||
```
|
||||
$TTL 86400
|
||||
@ -114,13 +114,13 @@ dns01 IN A 192.168.1.160
|
||||
client IN A 192.168.1.136
|
||||
```
|
||||
|
||||
Everything in _**bold**_ is specific to your environment. Save the file and exit. Next, edit the _reverse.fedora.local_ file:
|
||||
所有_**粗体**_内容都特定于你的环境。保存文件并退出。接下来,编辑 _reverse.fedora.local_ 文件:
|
||||
|
||||
```
|
||||
$ sudo vi /var/named/reverse.fedora.local
|
||||
```
|
||||
|
||||
Add the following lines:
|
||||
添加以下行:
|
||||
|
||||
```
|
||||
$TTL 86400
|
||||
@ -139,9 +139,10 @@ client IN A 192.168.1.136
|
||||
136 IN PTR client.fedora.local.
|
||||
```
|
||||
|
||||
Everything in _**bold**_ is also specific to your environment. Save the file and exit.
|
||||
所有_**粗体**_内容都特定于你的环境。保存文件并退出。
|
||||
|
||||
你还需要配置 SELinux 并为配置文件添加正确的所有权。
|
||||
|
||||
You’ll also need to configure SELinux and add the correct ownership for the configuration files.
|
||||
|
||||
```
|
||||
sudo chgrp named -R /var/named
|
||||
@ -150,22 +151,22 @@ sudo restorecon -rv /var/named
|
||||
sudo restorecon /etc/named.conf
|
||||
```
|
||||
|
||||
Configure the firewall:
|
||||
配置防火墙:
|
||||
|
||||
```
|
||||
sudo firewall-cmd --add-service=dns --perm
|
||||
sudo firewall-cmd --reload
|
||||
```
|
||||
|
||||
#### Check the configuration for any syntax errors
|
||||
#### 检查配置是否存在语法错误
|
||||
|
||||
```
|
||||
sudo named-checkconf /etc/named.conf
|
||||
```
|
||||
|
||||
Your configuration is valid if no output or errors are returned.
|
||||
如果没有输出或返回错误,那么你的配置有效。
|
||||
|
||||
Check the forward and reverse zone files.
|
||||
检查转发和反向区域文件。
|
||||
|
||||
```
|
||||
$ sudo named-checkzone forward.fedora.local /var/named/forward.fedora.local
|
||||
@ -173,7 +174,7 @@ $ sudo named-checkzone forward.fedora.local /var/named/forward.fedora.local
|
||||
$ sudo named-checkzone reverse.fedora.local /var/named/reverse.fedora.local
|
||||
```
|
||||
|
||||
You should see a response of OK:
|
||||
你应该看到 OK 的响应:
|
||||
|
||||
```
|
||||
zone forward.fedora.local/IN: loaded serial 2011071001
|
||||
@ -183,50 +184,50 @@ zone reverse.fedora.local/IN: loaded serial 2011071001
|
||||
OK
|
||||
```
|
||||
|
||||
#### Enable and start the DNS service
|
||||
#### 启用并启动 DNS 服务
|
||||
|
||||
```
|
||||
$ sudo systemctl enable named
|
||||
$ sudo systemctl start named
|
||||
```
|
||||
|
||||
#### Configuring the resolv.conf file
|
||||
#### 配置 resolv.conf 文件
|
||||
|
||||
Edit the _/etc/resolv.conf_ file:
|
||||
编辑 _/etc/resolv.conf_ 文件:
|
||||
|
||||
```
|
||||
$ sudo vi /etc/resolv.conf
|
||||
```
|
||||
|
||||
Look for your current name server line or lines. On the example system, a cable modem/router is serving as the name server and so it currently looks like this:
|
||||
查找你当前的 nameserver 行。在示例系统上,调制解调器/路由器充当名称服务器,因此当前看起来像这样:
|
||||
|
||||
```
|
||||
nameserver 192.168.1.1
|
||||
```
|
||||
|
||||
This needs to be changed to the IP address of the Master DNS server:
|
||||
这需要更改为主 DNS 服务器的 IP 地址:
|
||||
|
||||
```
|
||||
nameserver 192.168.1.160
|
||||
```
|
||||
|
||||
Save your changes and exit.
|
||||
保存更改并退出。
|
||||
|
||||
Unfortunately there is one caveat to be aware of. NetworkManager overwrites the _/etc/resolv.conf_ file if the system is rebooted or networking gets restarted. This means you will lose all of the changes that you made.
|
||||
不幸的是需要注意一点。如果系统重启或网络重启,那么 NetworkManager 会覆盖 _/etc/resolv.conf_ 文件。这意味着你将丢失所做的所有更改。
|
||||
|
||||
To prevent this from happening, make _/etc/resolv.conf_ immutable:
|
||||
为了防止这种情况发生,请将 _/etc/resolv.conf_ 设为不可变:
|
||||
|
||||
```
|
||||
$ sudo chattr +i /etc/resolv.conf
|
||||
```
|
||||
|
||||
If you want to set it back and allow it to be overwritten again:
|
||||
如果要重新设置并允许其再次被覆盖:
|
||||
|
||||
```
|
||||
$ sudo chattr -i /etc/resolv.conf
|
||||
```
|
||||
|
||||
#### Testing the DNS server
|
||||
#### 测试 DNS 服务器
|
||||
|
||||
```
|
||||
$ dig fedoramagazine.org
|
||||
@ -266,27 +267,27 @@ $ dig fedoramagazine.org
|
||||
;; MSG SIZE rcvd: 266
|
||||
```
|
||||
|
||||
There are a few things to look at to verify that the DNS server is working correctly. Obviously getting the results back are important, but that by itself doesn’t mean the DNS server is actually doing the work.
|
||||
有几件事需要检查以验证 DNS 服务器是否正常运行。显然,取得结果很重要,但这本身并不意味着 DNS 服务器实际上正常工作。
|
||||
|
||||
The QUERY, ANSWER, and AUTHORITY fields at the top should show non-zero as it in does in our example:
|
||||
顶部的 QUERY、ANSWER 和 AUTHORITY 字段应显示为非零,如我们的示例所示:
|
||||
|
||||
```
|
||||
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 6
|
||||
```
|
||||
|
||||
And the SERVER field should have the IP address of your DNS server:
|
||||
并且 SERVER 字段应有你的 DNS 服务器的 IP 地址:
|
||||
|
||||
```
|
||||
;; SERVER: 192.168.1.160#53(192.168.1.160)
|
||||
```
|
||||
|
||||
In case this is the first time you’ve run the _dig_ command, notice how it took 830 milliseconds for the query to complete:
|
||||
如果这是你第一次运行 _dig_ 命令,请注意完成查询要花费 830 毫秒的时间:
|
||||
|
||||
```
|
||||
;; Query time: 830 msec
|
||||
```
|
||||
|
||||
If you run it again, the query will run much quicker:
|
||||
如果再次运行它,查询将会更快:
|
||||
|
||||
```
|
||||
$ dig fedoramagazine.org
|
||||
@ -297,37 +298,37 @@ $ dig fedoramagazine.org
|
||||
;; SERVER: 192.168.1.160#53(192.168.1.160)
|
||||
```
|
||||
|
||||
### Client configuration
|
||||
### 客户端配置
|
||||
|
||||
The client configuration will be a lot simpler.
|
||||
客户端配置将简单得多。
|
||||
|
||||
Install the bind utilities:
|
||||
安装 bind 程序:
|
||||
|
||||
```
|
||||
$ sudo dnf install bind-utils -y
|
||||
```
|
||||
|
||||
Edit the /etc/resolv.conf file and configure the Master DNS as the only name server:
|
||||
编辑 /etc/resolv.conf 文件,并将主 DNS 配置为唯一的名称服务器:
|
||||
|
||||
```
|
||||
$ sudo vi /etc/resolv.conf
|
||||
```
|
||||
|
||||
This is how it should look:
|
||||
它看起来像这样:
|
||||
|
||||
```
|
||||
nameserver 192.168.1.160
|
||||
```
|
||||
|
||||
Save your changes and exit. Then, make the _/etc/resolv.conf_ file immutable to prevent it from be overwritten and going back to its default settings:
|
||||
保存更改并退出。然后,使 _/etc/resolv.conf_ 文件不可变,防止其被覆盖并变回默认设置:
|
||||
|
||||
```
|
||||
$ sudo chattr +i /etc/resolv.conf
|
||||
```
|
||||
|
||||
#### Testing the client
|
||||
#### 测试客户端
|
||||
|
||||
You should get the same results as you did from the DNS server:
|
||||
你应该获得与 DNS 服务器相同的结果:
|
||||
|
||||
```
|
||||
$ dig fedoramagazine.org
|
||||
@ -367,9 +368,9 @@ $ dig fedoramagazine.org
|
||||
;; MSG SIZE rcvd: 266
|
||||
```
|
||||
|
||||
Make sure the SERVER output has the IP Address of your DNS server.
|
||||
确保 SERVER 输出的是你 DNS 服务器的 IP 地址。
|
||||
|
||||
Your DNS server is now ready to use and all requests from the client should be going through your DNS server now!
|
||||
你的 DNS 服务器设置完成了,现在所有来自客户端的请求都会经过你的 DNS 服务器了!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -377,7 +378,7 @@ via: https://fedoramagazine.org/how-to-setup-a-dns-server-with-bind/
|
||||
|
||||
作者:[Curt Warfield][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
@ -0,0 +1,198 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Basic kubectl and Helm commands for beginners)
|
||||
[#]: via: (https://opensource.com/article/20/2/kubectl-helm-commands)
|
||||
[#]: author: (Jessica Cherry https://opensource.com/users/jrepka)
|
||||
|
||||
适用于初学者的基本 kubectl 和 Helm 命令
|
||||
======
|
||||
|
||||
> 像去杂货店购物一样,你需要用这些命令入门 Kubernetes。
|
||||
|
||||
![A person working.][1]
|
||||
|
||||
最近,我丈夫告诉我他即将要去参加一个工作面试,面试时他需要在计算机上运行一些基本命令。他对这场面试感到焦虑,但是对于他来说,学习和记住事情的最好方法是将不了解的事物比喻为非常熟悉的事物。因为我们的谈话是在我逛杂货店试图决定当晚要烹饪的食物之后进行的,所以这启发我用一次去杂货店的行程来描述 `kubectl` 和 `helm` 命令。
|
||||
|
||||
[Helm][2](“舵轮”)是在 Kubernetes(来自希腊语,意思是“舵手” 或 “领航员”)中管理应用程序的工具。你可以轻松地使用你的应用程序信息来部署“<ruby>海图<rt>chart</rt></ruby>”,从而可以在你的 Kubernetes 环境中几分钟之内让它们就绪并预配置好。在学习新知识时,查看示例的“海图”以了解其用法总是很有帮助的,因此,如果有时间,请查看这些稳定版的“[海图][3]”。
|
||||
|
||||
[kubectl][4] 是与 Kubernetes 环境的命令行界面,允许你配置和管理集群。它需要一些配置才能在环境中工作,因此请仔细阅读其[文档][5]以了解你需要做什么。
|
||||
|
||||
我将在示例中使用命名空间,你可以在我的文章《[Kubernetes 命名空间入门][6]》中了解它。
|
||||
|
||||
现在我们已经准备好了,让我们开始 `kubectl`和 `helm` 基本命令的购物之旅!
|
||||
|
||||
### 用 Helm 列出清单
|
||||
|
||||
你去商店之前要做的第一件事是什么?好吧,如果你做事有条理,就可以创建一个“清单”。同样,这是我将解释的第一个基本的 Helm 命令。
|
||||
|
||||
在一个用 Helm 部署的应用程序中,`list` 命令提供有关应用程序当前版本的详细信息。在此示例中,我有一个已部署的应用程序:Jenkins CI/CD 应用程序。运行基本的 `list` 命令总是会显示默认的命名空间。由于我没有在默认的命名空间中部署任何内容,因此不会显示任何内容:
|
||||
|
||||
```
|
||||
$helm list
|
||||
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
|
||||
```
|
||||
|
||||
但是,如果运行带有额外标志的命令,则会显示我的应用程序和信息:
|
||||
|
||||
```
|
||||
$helm list --all-namespaces
|
||||
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
|
||||
jenkins jenkins 1 2020-01-18 16:18:07 EST deployed jenkins-1.9.4 lts
|
||||
```
|
||||
|
||||
最后,我可以指示 `list` 命令只检查我想从中获取信息的命名空间:
|
||||
|
||||
```
|
||||
$helm list --namespace jenkins
|
||||
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
|
||||
jenkins jenkins 1 2020-01-18 16:18:07 EST deployed jenkins-1.9.4 lts
|
||||
```
|
||||
|
||||
现在我有了一个清单,并且知道该清单上有什么,我可以使用 `get` 命令来“获取”我的物品!我将从 Kubernetes 集群开始,我能从中获取到什么?
|
||||
|
||||
### 用 Kubectl 获取物品
|
||||
|
||||
`kubectl get` 命令提供有关 Kubernetes 中许多事物的信息,包括“<ruby>吊舱<rt>Pod</rt></ruby>”、节点和命名空间。同样,没有指定命名空间标志,你就会使用默认的命名空间。首先,我获取集群中的命名空间以查看正在运行的命名空间:
|
||||
|
||||
```
|
||||
$kubectl get namespaces
|
||||
NAME STATUS AGE
|
||||
default Active 53m
|
||||
jenkins Active 44m
|
||||
kube-node-lease Active 53m
|
||||
kube-public Active 53m
|
||||
kube-system Active 53m
|
||||
```
|
||||
|
||||
现在我已经知道了在我的环境中运行的命名空间了,接下来将获取节点并查看有多少个正在运行:
|
||||
|
||||
```
|
||||
$kubectl get nodes
|
||||
NAME STATUS ROLES AGE VERSION
|
||||
minikube Ready master 55m v1.16.2
|
||||
```
|
||||
|
||||
我有一个节点正在运行,这主要是因为我的 Minikube 运行在一台小型服务器上。要得到在我的这一个节点上运行的“吊舱”:
|
||||
|
||||
```
|
||||
$kubectl get pods
|
||||
No resources found in default namespace.
|
||||
```
|
||||
|
||||
啊哦,它是空的。我将通过以下方式获取 Jenkins 命名空间中的内容:
|
||||
|
||||
```
|
||||
$kubectl get pods --namespace jenkins
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
jenkins-7fc688c874-mh7gv 1/1 Running 0 40m
|
||||
```
|
||||
|
||||
好消息!这里有个“吊舱”,它还没有重新启动过,已运行了 40 分钟了。好的,我知道“吊舱”已经装好,所以我想看看用 Helm 命令可以得到什么。
|
||||
|
||||
### 用 Helm 获取信息
|
||||
|
||||
`helm get` 稍微复杂一点,因为这个“获取”命令所需要的不仅仅是一个应用程序名称,而且你可以从应用程序中请求多个内容。我将从获取用于制作应用程序的值开始,然后展示“获取全部”的操作结果的片段,该操作将提供与该应用程序相关的所有数据。
|
||||
|
||||
```
|
||||
$helm get values jenkins -n jenkins
|
||||
USER-SUPPLIED VALUES:
|
||||
null
|
||||
```
|
||||
|
||||
由于我最小限度的只安装了稳定版,因此配置没有更改。如果我运行“获取全部”命令,我将得到所有“海图”:
|
||||
|
||||
```
|
||||
$helm get all jenkins -n jenkins
|
||||
```
|
||||
|
||||
![output from helm get all command][7]
|
||||
|
||||
这会产生大量数据,因此我始终建议保留一份 Helm “海图”的副本,以便你可以查看“海图”中的模板。我还创建自己的值来了解自己所拥有的。
|
||||
|
||||
现在,我把所有的商品都放在购物车中了,我会检查一下“描述”它们包含什么的标签。这些示例仅与 `kubectl` 命令有关,它们描述了我通过 Helm 部署的内容。
|
||||
|
||||
### 用 kubectl 查看描述
|
||||
|
||||
正如我使用“获取”命令(该命令可以描述 Kubernetes 中的几乎所有内容)所做的那样,我将示例限制定命名空间、“吊舱”和节点上。由于我知道它们每一个是什么,因此这很容易。
|
||||
|
||||
```
|
||||
$kubectl describe ns jenkins
|
||||
Name: jenkins
|
||||
Labels: <none>
|
||||
Annotations: <none>
|
||||
Status: Active
|
||||
No resource quota.
|
||||
No resource limits.
|
||||
```
|
||||
|
||||
我可以看到我的命名空间的名称,并且它是活动的,没有资源或限额限制。
|
||||
|
||||
`describe pods` 命令会产生大量信息,因此我将提供一小段输出。如果你在不使用“吊舱”名称的情况下运行该命令,它将返回名称空间中所有“吊舱”的信息,这可能会很麻烦。因此,请确保在此命令中始终包含“吊舱”名称。例如:
|
||||
|
||||
```
|
||||
$kubectl describe pods jenkins-7fc688c874-mh7gv --namespace jenkins
|
||||
```
|
||||
|
||||
![output of kubectl-describe-pods][8]
|
||||
|
||||
这提供容器的状态、管理方式、标签以及“吊舱”中使用的镜像(还有很多其他信息)。不在这个简化过的输出中的数据包括资源请求和限制以及在 Helm 配置值文件中应用的任何条件、初始化容器和存储卷信息。如果你的应用程序由于资源不足而崩溃,或者是运行前置脚本进行配置的已初始化配置的容器,或者生成不应该存在于纯文本 YAML 文件中的隐藏密码,则此数据很有用。
|
||||
|
||||
最后,我将使用 `describe node` 命令,当然,它是用来描述节点的。由于本示例只有一个名为 Minikube 的示例,因此我将使用这个名字。如果你的环境中有多个节点,则必须包含你想查找的的节点名称。
|
||||
|
||||
与“吊舱”一样,这个节点的命令会产生大量数据,因此我将仅包括输出片段。
|
||||
|
||||
```
|
||||
$kubectl describe node minikube
|
||||
```
|
||||
|
||||
![output of kubectl describe node][9]
|
||||
|
||||
注意,`describe node` 是更重要的基本命令之一。如此图所示,该命令返回统计信息,该信息指示节点何时资源用尽,并且该数据非常适合在需要扩展时(如果你的环境中没有自动扩展)向你发出警报。此输出片段中未包含的其他内容包括对所有资源和限制的请求所占的百分比,以及资源的使用期限和分配(例如,对于我的应用程序而言)。
|
||||
|
||||
### 买单
|
||||
|
||||
使用这些命令,我完成了购物并得到了我想要的一切。希望这些基本命令也能在你使用 Kubernetes 的日常工作中提供帮助。
|
||||
|
||||
我鼓励你经常使用命令行并学习“帮助”部分中的速记标志,你可以通过运行以下命令来查看这些标志:
|
||||
|
||||
```
|
||||
$helm --help
|
||||
```
|
||||
|
||||
或
|
||||
|
||||
```
|
||||
$kubectl -h
|
||||
```
|
||||
|
||||
### 花生酱和果冻
|
||||
|
||||
有些东西像花生酱和果冻一样混在一起。Helm 和 `kubectl` 就有点像那样。
|
||||
|
||||
我经常在自己的环境中使用这些工具。因为它们在很多地方都有很多相似之处,所以在使用其中一个之后,我通常需要跟进另一个。例如,我可以进行 Helm 部署,并使用 `kubectl` 观察它是否失败。一起试试它们,看看它们能为你做什么。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/2/kubectl-helm-commands
|
||||
|
||||
作者:[Jessica Cherry][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[wxy](https://github.com/wxy)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/jrepka
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003784_02_os.comcareers_os_rh2x.png?itok=jbRfXinl (A person working.)
|
||||
[2]: https://helm.sh/
|
||||
[3]: https://github.com/helm/charts/tree/master/stable
|
||||
[4]: https://kubernetes.io/docs/reference/kubectl/kubectl/
|
||||
[5]: https://kubernetes.io/docs/reference/kubectl/overview/
|
||||
[6]: https://linux.cn/article-11749-1.html
|
||||
[7]: https://opensource.com/sites/default/files/uploads/helm-get-all.png (output from helm get all command)
|
||||
[8]: https://opensource.com/sites/default/files/uploads/kubectl-describe-pods.png (output of kubectl-describe-pods)
|
||||
[9]: https://opensource.com/sites/default/files/uploads/kubectl-describe-node.png (output of kubectl describe node)
|
Loading…
Reference in New Issue
Block a user