Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the four tools that help you navigate Kubernetes?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, the editor will bring you about the four tools to help you control Kubernetes. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

In Kubernetes, you have to learn the smallest set of primitives to model an application. I want to emphasize this point: the set of primitives you need to learn is the simplest set of primitives through which you can learn how to implement production-level application deployment (i.e. high availability [HA], multiple containers, multiple applications). In other words, learning Kubernetes's built-in set of primitives is easier than learning cluster software, cluster file systems, load balancers, maddening Apache and Nginx configurations, routers, switches, firewalls, and storage backends-- things you need to model simple HA applications in a traditional IT environment (virtual machine or bare metal).

In this fourth article, I will share some tools that can help you learn to navigate Kubernetes quickly.

1 、 Katacoda

There is no doubt that Katacoda is the easiest way to test drive a Kubernetes cluster. With one click, you can connect the Web-based terminal directly to the running Kubernetes cluster in five seconds. This is great for use and learning. I even use it to demonstrate and test new ideas. Katacoda provides a complete temporary environment that can be recycled after you use it.

OpenShift Playground

Kubernetes PlaygroundKatacoda provides a temporary environment and a deeper laboratory environment. For example, the Linux Container Internals Lab I've been talking about for the last three or four years is built in Katacoda.

Katacoda maintains several Kubernetes and cloud tutorials on its main site and works with Red Hat to support a dedicated learning portal for OpenShift. Learn about them. They are excellent learning resources.

2 、 Podman generate kube

The podman generate kube command is a great subcommand that helps users naturally transition from a simple container engine running simple containers to cluster use cases running many containers (as I described in the previous article). Podman does this by letting you start a new container, then export the working Kube YAML, and launch it in Kubernetes. Take a look at this (you can run it in Katacoda lab, it already has Podman and OpenShift).

First, notice that the syntax for running the container is very similar to Docker:

Podman run-dtn two-pizza quay.io/fatherlinux/two-pizza

But this is what other container engines don't have:

Podman generate kube two-pizza

Output:

# Generation of Kubernetes YAML is still under development! # # Save the output of this file and use kubectl create-f to import # it into Kubernetes. # # Created with podman-1.3.1 apiVersion: v1 kind: Pod metadata: creationTimestamp: "2019-06-07T08:08:12Z" labels: app: two-pizza name: two-pizza spec: containers:-command:-/ bin/sh-- c-bash-c 'while true; do / usr/bin/nc-l-p 3306 < / srv/hello.txt Done' env:-name: PATH value: / usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin-name: TERM value: xterm-name: HOSTNAME-name: container value: oci image: quay.io/fatherlinux/two-pizza:latest name: two-pizza resources: {} securityContext: allowPrivilegeEscalation: true Capabilities: {} privileged: false readOnlyRootFilesystem: false tty: true workingDir: / status: {}-apiVersion: v1 kind: Service metadata: creationTimestamp: "2019-06-07T08:08:12Z" labels: app: two-pizza name: two-pizza spec: selector: app: two-pizza type: NodePort status: loadBalancer: {}

Now that you have some possible work Kubernetes YAML, you can use it as a starting point for practice to learn, adjust, and so on. The-s logo can create a service for you. Brent Baude even works to add new features such as volume / persistent volume assertions. If you want to go further, learn about Brent's work in his blog post "Podman can now easily transition to Kubernetes and CRI-O."

3 、 oc new-app

The oc new-app command is very powerful. It is specific to OpenShift, so it is not available in the default Kubernetes, but it is very useful when you start learning Kubernetes. Let's start with quick commands to create a fairly complex application:

Oc new-project-n example oc new-app-f https://raw.githubusercontent.com/openshift/origin/master/examples/quickstarts/cakephp-mysql.json

With oc new-app, you can steal templates from OpenShift developers and have a known good starting point when developing primitives to describe your own applications. After running the above command, your Kubernetes namespace (in OpenShift) will be populated with several new defined resources.

Oc get all

Output:

NAME READY STATUS RESTARTS AGE pod/cakephp-mysql-example-1-build 0/1 Completed 0 4m pod/cakephp-mysql-example-1-gz65l 1/1 Running 0 1m pod/mysql-1-nkhqn 1/1 Running 0 4m NAME DESIRED CURRENT READY AGE replicationcontroller/cakephp-mysql-example-1 1 1 1 1m replicationcontroller/mysql-1 1 1 1 4m NAME TYPE CLUSTER-IP EXTERNAL-IP PORT (S) AGE service/cakephp-mysql-example ClusterIP 172.30.234.135 8080/TCP 4m service/mysql ClusterIP 172.30.13.195 3306/TCP 4m NAME REVISION DESIRED CURRENT TRIGGERED BY deploymentconfig.apps.openshift.io/cakephp-mysql-example 1 1 1 config Image (cakephp-mysql-example:latest) deploymentconfig.apps.openshift.io/mysql 1 1 1 config Image (mysql:5.7) NAME TYPE FROM LATEST buildconfig.build.openshift.io/cakephp-mysql-example Source Git 1 NAME TYPE FROM STATUS STARTED DURATION build.build.openshift.io/cakephp-mysql-example-1 Source Git@47a951e Complete 4 minutes ago 2m27s NAME DOCKER REPO TAGS UPDATED imagestream.image.openshift.io/cakephp-mysql-example docker-registry.default.svc:5000/example/cakephp-mysql-example latest About aminute ago NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD route.route.openshift.io/cakephp-mysql-example cakephp-mysql-example-example.2886795271-80-rhsummit1.environments.katacoda.com cakephp-mysql-example None

The advantage of this is that you can delete the Pod, observe how the replication controller recreates them, scale the Pod, and so on. You can use the template and change it to another application (this is what I did when I started it every time).

4 、 Visual Studio Code

I put my favorite in *. I use vi for most of my work, but I've never found a good syntax highlight and code completion plug-in for Kubernetes (if any, please let me know). Instead, I found that Microsoft VS Code has a set of killer plug-ins that can complete the creation of Kubernetes resources and provide templates.

VS Code plugins UI first install the Kubernetes and YAML plug-ins shown in the figure above.

Autocomplete in VS Code then you can create a new YAML file from scratch and automatically fill up the Kubernetes resources. The above example shows a service.

VS Code autocomplete filling in boilerplate for an object when you use autocomplete and select a service resource, it populates some templates for that object. This is great when you learn to use Kubernetes for the first time. You can build Pod, services, replication controllers, deployments, etc. This is a great feature when you build these files from scratch or even modify the files you create using podman generate kube.

These four tools (or six if you count two plug-ins) will help you learn to navigate Kubernetes rather than building or equipping it.

These are the four tools that Xiaobian shared to help you control Kubernetes. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report