mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-30 02:40:11 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
5bee88e8e3
sources/tech
20201012 Build a Kubernetes Minecraft server with Ansible-s Helm modules.md20201028 What-s new in Fedora 33 Workstation.md20201102 4 cool new projects to try in COPR from October 2020.md20201103 4 ways to run Kubernetes locally.md20201103 Create a list in a Flutter mobile app.md20201103 How the Kubernetes scheduler works.md
translated/tech
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (HankChow)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -1,81 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (What’s new in Fedora 33 Workstation)
|
||||
[#]: via: (https://fedoramagazine.org/whats-new-fedora-33-workstation/)
|
||||
[#]: author: (Gregory Bartholomew https://fedoramagazine.org/author/glb/)
|
||||
|
||||
What’s new in Fedora 33 Workstation
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
Fedora 33 Workstation is the [latest release][2] of our free, leading-edge operating system. You can download it from [the official website here][3] right now. There are several new and noteworthy changes in Fedora 33 Workstation. Read more details below.
|
||||
|
||||
### GNOME 3.38
|
||||
|
||||
Fedora 33 Workstation includes the latest release of GNOME Desktop Environment for users of all types. GNOME 3.38 in Fedora 33 Workstation includes many updates and improvements, including:
|
||||
|
||||
#### A new GNOME Tour app
|
||||
|
||||
New users are now greeted by “a new _Tour_ application, highlighting the main functionality of the desktop and providing first time users a nice welcome to GNOME.”
|
||||
|
||||
![The new GNOME Tour application in Fedora 33][4]
|
||||
|
||||
#### Drag to reorder apps
|
||||
|
||||
GNOME 3.38 replaces the previously split Frequent and All apps views with a single customizable and consistent view that allows you to reorder apps and organize them into custom folders. Simply click and drag to move apps around.
|
||||
|
||||
![GNOME 3.38 Drag to Reorder][5]
|
||||
|
||||
#### Improved screen recording
|
||||
|
||||
The screen recording infrastructure in GNOME Shell has been improved to take advantage of PipeWire and kernel APIs. This will help reduce resource consumption and improve responsiveness.
|
||||
|
||||
GNOME 3.38 also provides many additional features and enhancements. Check out the [GNOME 3.38 Release Notes][6] for further information.
|
||||
|
||||
* * *
|
||||
|
||||
### B-tree file system
|
||||
|
||||
As [announced previously][7], new installations of Fedora 33 will default to using [Btrfs][8]. Features and enhancements are added to Btrfs with each new kernel release. The [change log][9] has a complete summary of the features that each new kernel version brings to Btrfs.
|
||||
|
||||
* * *
|
||||
|
||||
### Swap on ZRAM
|
||||
|
||||
Anaconda and Fedora IoT have been using swap-on-zram by default for years. With Fedora 33, swap-on-zram will be enabled by default instead of a swap partition. Check out [the Fedora wiki page][10] for more details about swap-on-zram.
|
||||
|
||||
* * *
|
||||
|
||||
### Nano by default
|
||||
|
||||
Fresh Fedora 33 installations will set the EDITOR environment variable to [_nano_ by default][11]. This change affects several command line tools that spawn a text editor when they require user input. With earlier releases, this environment variable default was unspecified, leaving it up to the individual application to pick a default editor. Typically, applications would use _[vi][12]_ as their default editor due to it being a small application that is traditionally available on the base installation of most Unix/Linux operating systems. Since Fedora 33 includes nano in its base installation, and since nano is more intuitive for a beginning user to use, Fedora 33 will use nano by default. Users who want vi can, of course, override the value of the EDITOR variable in their own environment. See [the Fedora change request][11] for more details.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/whats-new-fedora-33-workstation/
|
||||
|
||||
作者:[Gregory Bartholomew][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/glb/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://fedoramagazine.org/wp-content/uploads/2020/10/f33workstation-816x345.jpg
|
||||
[2]: https://fedoramagazine.org/announcing-fedora-33/
|
||||
[3]: https://getfedora.org/workstation
|
||||
[4]: https://fedoramagazine.org/wp-content/uploads/2020/10/fedora-33-gnome-tour-1.png
|
||||
[5]: https://fedoramagazine.org/wp-content/uploads/2020/10/drag-to-reorder-1.gif
|
||||
[6]: https://help.gnome.org/misc/release-notes/3.38/
|
||||
[7]: https://fedoramagazine.org/btrfs-coming-to-fedora-33/
|
||||
[8]: https://en.wikipedia.org/wiki/Btrfs
|
||||
[9]: https://btrfs.wiki.kernel.org/index.php/Changelog#By_feature
|
||||
[10]: https://fedoraproject.org/wiki/Changes/SwapOnZRAM
|
||||
[11]: https://fedoraproject.org/wiki/Changes/UseNanoByDefault
|
||||
[12]: https://en.wikipedia.org/wiki/Vi
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
137
sources/tech/20201103 4 ways to run Kubernetes locally.md
Normal file
137
sources/tech/20201103 4 ways to run Kubernetes locally.md
Normal file
@ -0,0 +1,137 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (4 ways to run Kubernetes locally)
|
||||
[#]: via: (https://opensource.com/article/20/11/run-kubernetes-locally)
|
||||
[#]: author: (Bryant Son https://opensource.com/users/brson)
|
||||
|
||||
4 ways to run Kubernetes locally
|
||||
======
|
||||
Set up a local development environment or just try out the container
|
||||
orchestration platform with these tools.
|
||||
![Business woman on laptop sitting in front of window][1]
|
||||
|
||||
[Kubernetes][2] is an open source orchestration platform for containers. Developed by Google, it offers an open source system for automating deployment, scaling, and managing containerized applications. Although most people run Kubernetes in a cloud environment, running a Kubernetes cluster locally is not only possible, it has at least two benefits:
|
||||
|
||||
* You can quickly try out Kubernetes before deciding to use it as your primary platform to deploy your application.
|
||||
* You can set it up as a local development environment before pushing anything to a public cloud, thus allowing separation between the development environment and the production environment.
|
||||
|
||||
|
||||
|
||||
Setting up a local Kubernetes environment as your development environment is the recommended option, no matter your situation, because this setup can create a safe and agile application-deployment process.
|
||||
|
||||
Fortunately, there are multiple platforms that you can try out to run Kubernetes locally, and they are all open source and available under the [Apache 2.0][3] license.
|
||||
|
||||
* [Minikube][4] has the primary goals of being the best tool for local Kubernetes application development, and to support all Kubernetes features that fit.
|
||||
* [kind][5] runs local Kubernetes clusters using Docker container "nodes."
|
||||
* [CodeReady Containers][6] (CRC) manages a local OpenShift 4.x cluster optimized for testing and development purposes.
|
||||
* [Minishift][7] helps you run OpenShift 3.x clusters locally by running a single-node OpenShift cluster inside a virtual machine (VM).
|
||||
|
||||
|
||||
|
||||
### Minikube
|
||||
|
||||
![Minikube][8]
|
||||
|
||||
(Bryant Son, [CC BY-SA 4.0][9])
|
||||
|
||||
[Minikube][10] is the most well-known and popular choice to run a Kubernetes environment on a local computer. No matter what operating system you use, [Minikube's documentation][11] offers an easy [installation][12] guide for you. Generally, installing Minikube is as simple as running two commands:
|
||||
|
||||
|
||||
```
|
||||
$ curl -LO <https://storage.googleapis.com/minikube/releases/latest/minikube-PLATFORM-amd64>
|
||||
$ sudo install minikube-PLATFORM-amd64 /usr/local/bin/minikube
|
||||
```
|
||||
|
||||
Minikube quickly sets up a local Kubernetes cluster on Linux, macOS, or Windows with the following features:
|
||||
|
||||
* Supports the latest Kubernetes release (+6 previous minor versions)
|
||||
* Cross-platform (Linux, macOS, Windows)
|
||||
* Deploys as a VM, a container, or on bare-metal
|
||||
* Multiple container runtimes (CRI-O, containerd, Docker)
|
||||
* Docker API endpoint for blazing-fast image pushes
|
||||
* LoadBalancer, filesystem mounts, FeatureGates, and other advanced features
|
||||
* Add-ons for easily installing Kubernetes applications
|
||||
|
||||
|
||||
|
||||
Because Minikube is an open source project, you can contribute to its [source code][4].
|
||||
|
||||
### kind
|
||||
|
||||
![kind][13]
|
||||
|
||||
(Bryant Son, [CC BY-SA 4.0][9])
|
||||
|
||||
[kind][14]'s developers describe it as "a tool for running local Kubernetes clusters using Docker container 'nodes.'" It was designed for testing Kubernetes but may also be used for local development or continuous integration.
|
||||
|
||||
kind supports:
|
||||
|
||||
* Multi-node (including high-availability) clusters
|
||||
* Building Kubernetes release builds from source
|
||||
* Make/Bash/Docker or Bazel, in addition to pre-published builds
|
||||
* Linux, macOS, and Windows
|
||||
|
||||
|
||||
|
||||
In addition, kind is a Cloud Native Computing Foundation (CNCF)-certified conformant Kubernetes installer. Because it's open source, you can find kind's [source code][5] in its GitHub repository.
|
||||
|
||||
### CodeReady Container (CRC)
|
||||
|
||||
![CodeReady Container][15]
|
||||
|
||||
(Bryant Son, [CC BY-SA 4.0][9])
|
||||
|
||||
If you want to try the latest version of OpenShift locally, try Red Hat [CodeReady Containers][16] (CRC). CRC brings a minimal OpenShift 4.x cluster to your local computer that provides a minimal environment for development and testing purposes. CRC is mainly targeted for use on developers' desktops.
|
||||
|
||||
You can find CodeReady Container's [source code][6] on GitHub, also available under the Apache 2.0 license.
|
||||
|
||||
### Minishift
|
||||
|
||||
![Minishift][17]
|
||||
|
||||
(Bryant Son, [CC BY-SA 4.0][9])
|
||||
|
||||
The [Minishift][7] project [helps you run a version of OpenShift][18] with [OKD][19] locally with a single-node OpenShift cluster inside a virtual machine. You can use it to [try OpenShift][20] or to develop for the cloud, on your local host.
|
||||
|
||||
Like the other tools on this list, Minishift is open source, and you can access its [source code][7] on GitHub.
|
||||
|
||||
### Kubernetes for the people
|
||||
|
||||
As you can see, there are several ways to try out Kubernetes in your local environment. Did I miss anything? Feel free to leave a comment to ask a question or make a suggestion.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/11/run-kubernetes-locally
|
||||
|
||||
作者:[Bryant Son][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/brson
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-concentration-focus-windows-office.png?itok=-8E2ihcF (Woman using laptop concentrating)
|
||||
[2]: https://kubernetes.io/
|
||||
[3]: https://www.apache.org/licenses/LICENSE-2.0
|
||||
[4]: https://github.com/kubernetes/minikube
|
||||
[5]: https://github.com/kubernetes-sigs/kind
|
||||
[6]: https://github.com/code-ready/crc
|
||||
[7]: https://github.com/minishift/minishift
|
||||
[8]: https://opensource.com/sites/default/files/uploads/1_minikube.jpg (Minikube)
|
||||
[9]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[10]: https://minikube.sigs.k8s.io/docs/
|
||||
[11]: https://minikube.sigs.k8s.io/docs
|
||||
[12]: https://minikube.sigs.k8s.io/docs/start/
|
||||
[13]: https://opensource.com/sites/default/files/uploads/2_kind.jpg (kind)
|
||||
[14]: https://kind.sigs.k8s.io
|
||||
[15]: https://opensource.com/sites/default/files/uploads/4_crc.jpg (CodeReady Container)
|
||||
[16]: https://code-ready.github.io/crc
|
||||
[17]: https://opensource.com/sites/default/files/uploads/3_minishift.jpg (Minishift)
|
||||
[18]: https://www.redhat.com/sysadmin/kubernetes-cluster-laptop
|
||||
[19]: https://www.okd.io/
|
||||
[20]: https://www.redhat.com/sysadmin/learn-openshift-minishift
|
379
sources/tech/20201103 Create a list in a Flutter mobile app.md
Normal file
379
sources/tech/20201103 Create a list in a Flutter mobile app.md
Normal file
@ -0,0 +1,379 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Create a list in a Flutter mobile app)
|
||||
[#]: via: (https://opensource.com/article/20/11/flutter-lists-mobile-app)
|
||||
[#]: author: (Vitaly Kuprenko https://opensource.com/users/kooper)
|
||||
|
||||
Create a list in a Flutter mobile app
|
||||
======
|
||||
Learn how to create Flutter app screens and pass data between them.
|
||||
![Mobile devices and collaboration leads to staring at our phones][1]
|
||||
|
||||
Flutter is a popular open source toolkit for building cross-platform apps. In "[Create a mobile app with Flutter][2]," I demonstrated how to install [Flutter][3] on Linux and create your first app. In this article, I'll show you how to add a list of items in your app, with each item opening a new screen. This is a common design method for mobile apps, so you've probably seen it before, but here's a screenshot to help you visualize it:
|
||||
|
||||
![Testing the Flutter app][4]
|
||||
|
||||
(Vitaly Kuprenko, [CC BY-SA 4.0][5])
|
||||
|
||||
Flutter uses the [Dart][6] language. In some of the code snippets below, you'll see statements beginning with slashes. Two slashes (`/ /`) is for code comments, which explain certain pieces of code. Three slashes (`/ / /`) denotes Dart's documentation comments, which explain Dart classes and their properties and other useful information.
|
||||
|
||||
### Examine a Flutter app's main parts
|
||||
|
||||
A typical entry point for a Flutter application is a `main()` function, usually found in a file called `lib/main.dart`:
|
||||
|
||||
|
||||
```
|
||||
void main() {
|
||||
runApp(MyApp());
|
||||
}
|
||||
```
|
||||
|
||||
This method is called when the app is launched. It runs `MyApp()`, a StatelessWidget containing all necessary app settings in the `MaterialApp()` widget (app theme, initial page to open, and so on):
|
||||
|
||||
|
||||
```
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.blue,
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
),
|
||||
home: MyHomePage(title: 'Flutter Demo Home Page'),
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The initial page generated is called `MyHomePage()`. It's a stateful widget that contains variables that can be passed to a widget constructor parameter (take a look at the code above, where you pass the variable `title` to the page constructor):
|
||||
|
||||
|
||||
```
|
||||
class MyHomePage extends StatefulWidget {
|
||||
MyHomePage({[Key][7] key, this.title}) : super(key: key);
|
||||
|
||||
final [String][8] title;
|
||||
|
||||
@override
|
||||
_MyHomePageState createState() => _MyHomePageState();
|
||||
}
|
||||
```
|
||||
|
||||
StatefulWidget means that this page has its own state: `_MyHomePageState`. It lets you call the `setState()` method there to rebuild the page's user interface (UI):
|
||||
|
||||
|
||||
```
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
int _counter = 0; // Number of taps on + button.
|
||||
|
||||
void _incrementCounter() { // Increase number of taps and update UI by calling setState().
|
||||
setState(() {
|
||||
_counter++;
|
||||
});
|
||||
}
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
A `build()` function in stateful and stateless widgets is responsible for UI appearance:
|
||||
|
||||
|
||||
```
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold( // Page widget.
|
||||
appBar: AppBar( // Page app bar with title and back button if user can return to previous screen.
|
||||
title: Text(widget.title), // Text to display page title.
|
||||
),
|
||||
body: Center( // Widget to center child widget.
|
||||
child: Column( // Display children widgets in column.
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text( // Static text.
|
||||
'You have pushed the button this many times:',
|
||||
),
|
||||
Text( // Text with our taps number.
|
||||
'$_counter', // $ sign allows us to use variables inside a string.
|
||||
style: Theme.of(context).textTheme.headline4,// Style of the text, “Theme.of(context)” takes our context and allows us to access our global app theme.
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Floating action button to increment _counter number.
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: _incrementCounter,
|
||||
tooltip: 'Increment',
|
||||
child: [Icon][9](Icons.add),
|
||||
),
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### Modify your app
|
||||
|
||||
It's good practice to separate the `main()` method and other pages' code into different files. To do so, you need to create a new .dart file by right-clicking on the **lib** folder then selecting **New > Dart File**:
|
||||
|
||||
![Create a new Dart file][10]
|
||||
|
||||
(Vitaly Kuprenko, [CC BY-SA 4.0][5])
|
||||
|
||||
Name the file `items_list_page`.
|
||||
|
||||
Switch back to your `main.dart` file, cut the `MyHomePage` and `_MyHomePageState` code, and paste it into your new file. Next, set your cursor on `StatefulWidget` (underlined below in red), press Alt+Enter, and select `package:flutter/material.dart`:
|
||||
|
||||
![Importing Flutter package][11]
|
||||
|
||||
(Vitaly Kuprenko, [CC BY-SA 4.0][5])
|
||||
|
||||
This adds `flutter/material.dart` to your file so that you can use the default material widgets Flutter provides.
|
||||
|
||||
Then, right-click on **MyHomePage class > Refactor > Rename…** and rename this class to `ItemsListPage`:
|
||||
|
||||
![Renaming StatefulWidget class][12]
|
||||
|
||||
(Vitaly Kuprenko, [CC BY-SA 4.0][5])
|
||||
|
||||
Flutter recognizes that you renamed the StatefulWidget class and automatically renames its State class:
|
||||
|
||||
![State class renamed automatically][13]
|
||||
|
||||
(Vitaly Kuprenko, [CC BY-SA 4.0][5])
|
||||
|
||||
Return to the `main.dart` file and change the name `MyHomePage` to `ItemsListPage`. Once you start typing, your Flutter integrated development environment (probably IntelliJ IDEA Community Edition, Android Studio, and VS Code or [VSCodium][14]) suggests how to autocomplete your code:
|
||||
|
||||
![IDE suggests autocompleting code][15]
|
||||
|
||||
(Vitaly Kuprenko, [CC BY-SA 4.0][5])
|
||||
|
||||
Press Enter to complete your input. It will add the missing import to the top of the file automatically:
|
||||
|
||||
![Adding missing import ][16]
|
||||
|
||||
(Vitaly Kuprenko, [CC BY-SA 4.0][5])
|
||||
|
||||
You've completed your initial setup. Now you need to create a new .dart file in the **lib** folder and name it `item_model`. (Note that classes have UpperCamelCase names, but files have snake_case names.) Paste this code into the new file:
|
||||
|
||||
|
||||
```
|
||||
/// Class that stores list item info:
|
||||
/// [id] - unique identifier, number.
|
||||
/// [icon] - icon to display in UI.
|
||||
/// [title] - text title of the item.
|
||||
/// [description] - text description of the item.
|
||||
class ItemModel {
|
||||
// class constructor
|
||||
ItemModel(this.id, this.icon, this.title, this.description);
|
||||
|
||||
// class fields
|
||||
final int id;
|
||||
final IconData icon;
|
||||
final [String][8] title;
|
||||
final [String][8] description;
|
||||
}
|
||||
```
|
||||
|
||||
Return to `items_list_page.dart`, and replace the existing `_ItemsListPageState` code with:
|
||||
|
||||
|
||||
```
|
||||
class _ItemsListPageState extends State<ItemsListPage> {
|
||||
|
||||
// Hard-coded list of [ItemModel] to be displayed on our page.
|
||||
final List<ItemModel> _items = [
|
||||
ItemModel(0, Icons.account_balance, 'Balance', 'Some info'),
|
||||
ItemModel(1, Icons.account_balance_wallet, 'Balance wallet', 'Some info'),
|
||||
ItemModel(2, Icons.alarm, 'Alarm', 'Some info'),
|
||||
ItemModel(3, Icons.my_location, 'My location', 'Some info'),
|
||||
ItemModel(4, Icons.laptop, 'Laptop', 'Some info'),
|
||||
ItemModel(5, Icons.backup, 'Backup', 'Some info'),
|
||||
ItemModel(6, Icons.settings, 'Settings', 'Some info'),
|
||||
ItemModel(7, Icons.call, 'Call', 'Some info'),
|
||||
ItemModel(8, Icons.restore, 'Restore', 'Some info'),
|
||||
ItemModel(9, Icons.camera_alt, 'Camera', 'Some info'),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(widget.title),
|
||||
),
|
||||
body: [ListView][17].builder( // Widget which creates [ItemWidget] in scrollable list.
|
||||
itemCount: _items.length, // Number of widget to be created.
|
||||
itemBuilder: (context, itemIndex) => // Builder function for every item with index.
|
||||
ItemWidget(_items[itemIndex], () {
|
||||
_onItemTap(context, itemIndex);
|
||||
}),
|
||||
));
|
||||
}
|
||||
|
||||
// Method which uses BuildContext to push (open) new MaterialPageRoute (representation of the screen in Flutter navigation model) with ItemDetailsPage (StateFullWidget with UI for page) in builder.
|
||||
_onItemTap(BuildContext context, int itemIndex) {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) => ItemDetailsPage(_items[itemIndex])));
|
||||
}
|
||||
}
|
||||
|
||||
// StatelessWidget with UI for our ItemModel-s in ListView.
|
||||
class ItemWidget extends StatelessWidget {
|
||||
const ItemWidget(this.model, this.onItemTap, {[Key][7] key}) : super(key: key);
|
||||
|
||||
final ItemModel model;
|
||||
final Function onItemTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell( // Enables taps for child and add ripple effect when child widget is long pressed.
|
||||
onTap: onItemTap,
|
||||
child: ListTile( // Useful standard widget for displaying something in ListView.
|
||||
leading: [Icon][9](model.icon),
|
||||
title: Text(model.title),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Consider moving `ItemWidget` to a separate file in the **lib** folder to improve the readability of your code.
|
||||
|
||||
The only thing missing is the `ItemDetailsPage` class. Create a new file in the **lib** folder and name it `item_details_page`. Then copy and paste this code there:
|
||||
|
||||
|
||||
```
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'item_model.dart';
|
||||
|
||||
/// Widget for displaying detailed info of [ItemModel]
|
||||
class ItemDetailsPage extends StatefulWidget {
|
||||
final ItemModel model;
|
||||
|
||||
const ItemDetailsPage(this.model, {[Key][7] key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_ItemDetailsPageState createState() => _ItemDetailsPageState();
|
||||
}
|
||||
|
||||
class _ItemDetailsPageState extends State<ItemDetailsPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(widget.model.title),
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 16),
|
||||
[Icon][9](
|
||||
widget.model.icon,
|
||||
size: 100,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Item description: ${widget.model.description}',
|
||||
style: TextStyle(fontSize: 18),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Almost nothing new here. Notice that `_ItemDetailsPageState` is using the `widget.item.title` code. It enables referring to the `StatefulWidget` fields in its `State` class.
|
||||
|
||||
### Add some animation
|
||||
|
||||
Now, it's time to add some basic animation:
|
||||
|
||||
1. Go to `ItemWidget` code.
|
||||
2. Put the cursor on the `Icon()` widget in the `build()` method.
|
||||
3. Press Alt+Enter and select "Wrap with widget…"
|
||||
|
||||
|
||||
|
||||
![Wrap with widget option][18]
|
||||
|
||||
(Vitaly Kuprenko, [CC BY-SA 4.0][5])
|
||||
|
||||
Start typing "Hero" and select the suggestion for `Hero((Key key, @required this, tag, this.create))`:
|
||||
|
||||
![Finding the Hero widget][19]
|
||||
|
||||
(Vitaly Kuprenko, [CC BY-SA 4.0][5])
|
||||
|
||||
Next, add the tag property `tag: model.id` to the Hero widget:
|
||||
|
||||
![Adding the tag property model.id to the Hero widget][20]
|
||||
|
||||
(Vitaly Kuprenko, [CC BY-SA 4.0][5])
|
||||
|
||||
And the final step is to make the same change in the `item_details_page.dart` file:
|
||||
|
||||
![Changing item_details_page.dart file][21]
|
||||
|
||||
(Vitaly Kuprenko, [CC BY-SA 4.0][5])
|
||||
|
||||
The previous steps wrapped the `Icon()` widget with the `Hero()` widget. Do you remember in `ItemModel` you added the `id field` but didn't use it anywhere? The Hero widget takes a unique tag for the child widget. If Hero detects that different app screens (MaterialPageRoute) have a Hero widget with the same tag, it'll automatically animate the transition between these pages.
|
||||
|
||||
Test it out by running the app on an Android emulator or physical device. When you open and close the item details page, you'll see a nice animation of the icon:
|
||||
|
||||
![Testing the Flutter app][4]
|
||||
|
||||
(Vitaly Kuprenko, [CC BY-SA 4.0][5])
|
||||
|
||||
### Wrapping up
|
||||
|
||||
In this tutorial, you learned:
|
||||
|
||||
* The components of a standard, automatically created app
|
||||
* How to add several pages that pass data among each other
|
||||
* How to add a simple animation for those pages
|
||||
|
||||
|
||||
|
||||
If you want to learn more, check out Flutter's [docs][22] (with links to sample projects, videos, and "recipes" for creating Flutter apps) and the [source code][23], which is open source under a BSD 3-Clause License.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/11/flutter-lists-mobile-app
|
||||
|
||||
作者:[Vitaly Kuprenko][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/kooper
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/team-phone-collaboration-mobile-device.png?itok=v3EjbRK6 (Mobile devices and collaboration leads to staring at our phones)
|
||||
[2]: https://opensource.com/article/20/9/mobile-app-flutter
|
||||
[3]: https://flutter.dev/
|
||||
[4]: https://opensource.com/sites/default/files/uploads/flutter_test.gif (Testing the Flutter app)
|
||||
[5]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[6]: https://dart.dev/
|
||||
[7]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+key
|
||||
[8]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string
|
||||
[9]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+icon
|
||||
[10]: https://opensource.com/sites/default/files/uploads/flutter_new-dart-file_0.png (Create a new Dart file)
|
||||
[11]: https://opensource.com/sites/default/files/uploads/flutter_import-package.png (Importing Flutter package)
|
||||
[12]: https://opensource.com/sites/default/files/uploads/flutter_rename-class.png (Renaming StatefulWidget class)
|
||||
[13]: https://opensource.com/sites/default/files/uploads/flutter_stateclassrenamed.png (State class renamed automatically)
|
||||
[14]: https://opensource.com/article/20/6/open-source-alternatives-vs-code
|
||||
[15]: https://opensource.com/sites/default/files/uploads/flutter_autocomplete.png (IDE suggests autocompleting code)
|
||||
[16]: https://opensource.com/sites/default/files/uploads/flutter_import-input.png (Adding missing import )
|
||||
[17]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+listview
|
||||
[18]: https://opensource.com/sites/default/files/uploads/flutter_wrapwithwidget.png (Wrap with widget option)
|
||||
[19]: https://opensource.com/sites/default/files/uploads/flutter_hero.png (Finding the Hero widget)
|
||||
[20]: https://opensource.com/sites/default/files/uploads/flutter_hero-tag.png (Adding the tag property model.id to the Hero widget)
|
||||
[21]: https://opensource.com/sites/default/files/uploads/flutter_details-tag.png (Changing item_details_page.dart file)
|
||||
[22]: https://flutter.dev/docs
|
||||
[23]: https://github.com/flutter
|
159
sources/tech/20201103 How the Kubernetes scheduler works.md
Normal file
159
sources/tech/20201103 How the Kubernetes scheduler works.md
Normal file
@ -0,0 +1,159 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How the Kubernetes scheduler works)
|
||||
[#]: via: (https://opensource.com/article/20/11/kubernetes-scheduler)
|
||||
[#]: author: (Mike Calizo https://opensource.com/users/mcalizo)
|
||||
|
||||
How the Kubernetes scheduler works
|
||||
======
|
||||
Understand how the Kubernetes scheduler discovers new pods and assigns
|
||||
them to nodes.
|
||||
![Parts, modules, containers for software][1]
|
||||
|
||||
[Kubernetes][2] has emerged as the standard orchestration engine for containers and containerized workloads. It provides a common, open source abstraction layer that spans public and private cloud environments.
|
||||
|
||||
For those already familiar with Kubernetes and its components, the conversation is usually around maximizing Kubernetes' power. But when you're just learning Kubernetes, it's wise to begin with some general knowledge about Kubernetes and its components (including the [Kubernetes scheduler][3]), as shown in this high-level view, before trying to use it in production.
|
||||
|
||||
![][4]
|
||||
|
||||
Kubernetes also uses control planes and nodes.
|
||||
|
||||
1. **Control plane:** Also known as master, these nodes are responsible for making global decisions about the clusters and detecting or responding to cluster events. The control plane components are:
|
||||
* etcd
|
||||
* kube-apiserver
|
||||
* kube-controller-manager
|
||||
* scheduler
|
||||
2. **Nodes:** Also called worker nodes, these sets of nodes are where a workload resides. They should always talk to the control plane to get the information necessary for the workload to run and to communicate and connect outside the cluster. Worker nodes' components are:
|
||||
* kubelet
|
||||
* kube-proxy
|
||||
* container runtime Interface.
|
||||
|
||||
|
||||
|
||||
I hope this background helps you understand how the Kubernetes components are stacked together.
|
||||
|
||||
### How Kubernetes scheduler works
|
||||
|
||||
A Kubernetes [pod][5] is comprised of one or more containers with shared storage and network resources. The Kubernetes scheduler's task is to ensure that each pod is assigned to a node to run on.
|
||||
|
||||
At a high level, here is how the Kubernetes scheduler works:
|
||||
|
||||
1. Every pod that needs to be scheduled is added to a queue
|
||||
2. When new pods are created, they are also added to the queue
|
||||
3. The scheduler continuously takes pods off that queue and schedules them
|
||||
|
||||
|
||||
|
||||
The [scheduler's code][6] (`scheduler.go`) is large, around 9,000 lines, and fairly complex, but the important bits to tackle are:
|
||||
|
||||
1. **Code that waits/watches for pod creation**
|
||||
The code that watches for pod creation begins on line 8970 of `scheduler.go`; it waits indefinitely for new pods:
|
||||
|
||||
|
||||
```
|
||||
// Run begins watching and scheduling. It waits for cache to be synced, then starts a goroutine and returns immediately.
|
||||
|
||||
func (sched *Scheduler) Run() {
|
||||
if !sched.config.WaitForCacheSync() {
|
||||
return
|
||||
}
|
||||
|
||||
go wait.Until(sched.scheduleOne, 0, sched.config.StopEverything)
|
||||
```
|
||||
|
||||
2. **Code that is responsible for queuing the pod**
|
||||
The function responsible for pod queuing is:
|
||||
|
||||
|
||||
```
|
||||
// queue for pods that need scheduling
|
||||
podQueue *cache.FIFO
|
||||
```
|
||||
|
||||
The code responsible for queuing the pod begins on line 7360 of `scheduler.go`. When the event handler is triggered to indicate that a new pod is available, this piece of code automatically puts the new pod in the queue:
|
||||
|
||||
|
||||
```
|
||||
func (f *ConfigFactory) getNextPod() *v1.Pod {
|
||||
for {
|
||||
pod := cache.Pop(f.podQueue).(*v1.Pod)
|
||||
if f.ResponsibleForPod(pod) {
|
||||
glog.V(4).Infof("About to try and schedule pod %v", pod.Name)
|
||||
return pod
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
3. **Code that handles errors**
|
||||
You will inevitably encounter scheduling errors in pod scheduling. The following code is how the scheduler handles the errors. It listens to `podInformer` and then spits out an error that the pod was not scheduled and terminates:
|
||||
|
||||
|
||||
```
|
||||
// scheduled pod cache
|
||||
podInformer.Informer().AddEventHandler(
|
||||
cache.FilteringResourceEventHandler{
|
||||
FilterFunc: func(obj interface{}) bool {
|
||||
switch t := obj.(type) {
|
||||
case *v1.Pod:
|
||||
return assignedNonTerminatedPod(t)
|
||||
default:
|
||||
runtime.HandleError(fmt.Errorf("unable to handle object in %T: %T", c, obj))
|
||||
return false
|
||||
}
|
||||
},
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
In other words, the Kubernetes scheduler is responsible for:
|
||||
|
||||
* Scheduling the newly created pods on nodes with enough space to satisfy the pod's resource needs
|
||||
* Listening to the kube-apiserver and the controller for the presence of newly created pods and then scheduling them to an available node on the cluster
|
||||
* Watching for unscheduled pods and binding them to nodes by using the `/binding` pod sub-resource API.
|
||||
|
||||
|
||||
|
||||
For example, imagine an application is being deployed that requires 1GB of memory and two CPU cores. Therefore, the pods for the application are created on a node that has enough resources available. Then, the scheduler continues to run forever, watching to see if there are pods that need to be scheduled.
|
||||
|
||||
### Learn more
|
||||
|
||||
To have a working Kubernetes cluster, you need to get all the components above working together in sync. The scheduler is a complex piece of code, but Kubernetes is awesome software, and currently, it's the default choice when talking about adopting cloud-native applications.
|
||||
|
||||
Learning Kubernetes requires time and effort, but having it as one of your skills will give you an edge that should bring rewards in your career. There are a lot of good learning resources available, and the [documentation][7] is good. If you are interested in learning more, I recommend starting with:
|
||||
|
||||
* [Kubernetes the hard way][8]
|
||||
* [Kubernetes the hard way on bare metal][9]
|
||||
* [Kubernetes the hard way on AWS][10]
|
||||
|
||||
|
||||
|
||||
What are your favorite ways to learn about Kubernetes? Please share in the comments.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/11/kubernetes-scheduler
|
||||
|
||||
作者:[Mike Calizo][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/mcalizo
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/containers_modules_networking_hardware_parts.png?itok=rPpVj92- (Parts, modules, containers for software)
|
||||
[2]: https://kubernetes.io/
|
||||
[3]: https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler/
|
||||
[4]: https://lh4.googleusercontent.com/egB0SSsAglwrZeWpIgX7MDF6u12oxujfoyY6uIPa8WLqeVHb8TYY_how57B4iqByELxvitaH6-zjAh795wxAB8zenOwoz2YSMIFRqHsMWD9ohvUTc3fNLCzo30r7lUynIHqcQIwmtRo
|
||||
[5]: https://kubernetes.io/docs/concepts/workloads/pods/
|
||||
[6]: https://github.com/kubernetes/kubernetes/blob/e4551d50e57c089aab6f67333412d3ca64bc09ae/plugin/pkg/scheduler/scheduler.go
|
||||
[7]: https://kubernetes.io/docs/home/
|
||||
[8]: https://github.com/kelseyhightower/kubernetes-the-hard-way
|
||||
[9]: https://github.com/Praqma/LearnKubernetes/blob/master/kamran/Kubernetes-The-Hard-Way-on-BareMetal.md
|
||||
[10]: https://github.com/Praqma/LearnKubernetes/blob/master/kamran/Kubernetes-The-Hard-Way-on-AWS.md
|
@ -0,0 +1,81 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (What’s new in Fedora 33 Workstation)
|
||||
[#]: via: (https://fedoramagazine.org/whats-new-fedora-33-workstation/)
|
||||
[#]: author: (Gregory Bartholomew https://fedoramagazine.org/author/glb/)
|
||||
|
||||
Fedora 33 Workstation 的新功能
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
Fedora 33 Workstation 是我们免费的、领先的操作系统的[最新版本][2]。你现在就可以从[官方网站][3]下载它。Fedora 33 Workstation 中有一些新的和值得注意的变化。请阅读更多如下细节。
|
||||
|
||||
### GNOME 3.38
|
||||
|
||||
Fedora 33 Workstation 为各类用户提供了最新版本的 GNOME 桌面环境。在 Fedora 33 Workstation 中的 GNOME 3.38 包含了许多更新和改进,包括:
|
||||
|
||||
#### 一个新的 GNOME Tour 应用
|
||||
|
||||
现在,新用户会看到一个“新的 _Tour_ 应用,高亮显示了桌面的主要功能,并为第一次使用 GNOME 的用户提供一个很好的欢迎”。
|
||||
|
||||
![The new GNOME Tour application in Fedora 33][4]
|
||||
|
||||
#### 拖动重排序应用
|
||||
|
||||
GNOME 3.38 用一个单一的可定制和一致的视图取代了之前分开的常用和所有应用视图,这允许你重新排列应用并将它们组织到自定义文件夹中。只需点击并拖动即可移动应用。
|
||||
|
||||
![GNOME 3.38 Drag to Reorder][5]
|
||||
|
||||
#### 改进屏幕录制
|
||||
|
||||
GNOME Shell 中的屏幕录制基础架构已被改进,以利用 PipeWire 和内核 API。这将有助于减少资源消耗并提高响应速度。
|
||||
|
||||
GNOME 3.38 还提供了许多额外的功能和改进。查看 [GNOME 3.38 发行说明][6]以获得更多信息。
|
||||
|
||||
* * *
|
||||
|
||||
### B-tree 文件系统
|
||||
|
||||
正如[之前宣布的][7],新安装的 Fedora 33 将默认使用 [Btrfs][8]。每一个新的内核版本都会为 Btrfs 增加一些特性和增强功能。[变更日志][9]有一个完整的总结,它介绍了每个新内核版本给 Btrfs 带来的功能。
|
||||
|
||||
* * *
|
||||
|
||||
### Swap on ZRAM
|
||||
|
||||
Anaconda 和 Fedora IoT 多年来一直默认使用 swap-on-zram。在 Fedora 33 中,swap-on-zram 将被默认启用,而不是 swap 分区。查看 [Fedora wiki 页面][10]了解更多关于 swap-on-zram 的细节。
|
||||
|
||||
* * *
|
||||
|
||||
### 默认使用 Nano
|
||||
|
||||
新的 Fedora 33 将把 EDITOR 环境变量默认设置为 [_nano_ ][11]。这个变化影响了一些命令行工具,当它们需要用户输入时,会打开一个文本编辑器。在早期的版本中,这个环境变量的默认值并没有被指定,而是由各个应用程序来选择一个默认的编辑器。通常情况下,应用程序会使用 [_vi_][12]作为它们的默认编辑器,因为它是一个小应用,通常在大多数 Unix/Linux 操作系统的基础安装中都可以使用。由于 Fedora 33 的基本安装中包含了 nano,而且 nano 对于初学者来说更加直观,所以 Fedora 33 将默认使用 nano。当然,想要使用 vi 的用户可以在自己的环境中覆盖 EDITOR 变量的值。详见[Fedora修改请求][11]获取更多信息。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/whats-new-fedora-33-workstation/
|
||||
|
||||
作者:[Gregory Bartholomew][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://fedoramagazine.org/author/glb/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://fedoramagazine.org/wp-content/uploads/2020/10/f33workstation-816x345.jpg
|
||||
[2]: https://fedoramagazine.org/announcing-fedora-33/
|
||||
[3]: https://getfedora.org/workstation
|
||||
[4]: https://fedoramagazine.org/wp-content/uploads/2020/10/fedora-33-gnome-tour-1.png
|
||||
[5]: https://fedoramagazine.org/wp-content/uploads/2020/10/drag-to-reorder-1.gif
|
||||
[6]: https://help.gnome.org/misc/release-notes/3.38/
|
||||
[7]: https://fedoramagazine.org/btrfs-coming-to-fedora-33/
|
||||
[8]: https://en.wikipedia.org/wiki/Btrfs
|
||||
[9]: https://btrfs.wiki.kernel.org/index.php/Changelog#By_feature
|
||||
[10]: https://fedoraproject.org/wiki/Changes/SwapOnZRAM
|
||||
[11]: https://fedoraproject.org/wiki/Changes/UseNanoByDefault
|
||||
[12]: https://en.wikipedia.org/wiki/Vi
|
Loading…
Reference in New Issue
Block a user