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

How to use GKE

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Editor to share with you how to use GKE, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Google's K8s has taken a leading position in the container choreography competition in 2017, from being squeezed out before Docker to finally fully embracing K8s, it is clear that K8s has become the current standard in the industry.

But so far, few cloud service providers can provide K8s fully managed services, even AWS, which is dominant in cloud providers, does not fully provide K8s managed services, only limited customized services, which is not mature in this aspect.

However, Google's K8s hosting service, that is, GKE, takes K8s hosting service to the extreme (at least for now). It not only provides a full range of K8s hosting services, but what is more striking is that Google has integrated Autoscaler and K8s, realizing the automatic scaling mechanism of k8s nodes, which can automatically add or delete nodes according to the needs of pod, and automatically add nodes to meet the needs when existing nodes are unable to host new services. When the existing node is idle enough, the adjustment mechanism will be enabled to automatically shrink the node, which in a sense almost achieves the idea of no server.

However, this may be just the tip of the iceberg, and more powerful features need to be further explored. This article is just a guide to getting started with Google Cloud Platform-based GKE services (K8s hosting services).

GKE getting started Guid

Next, we will give step-by-step instructions on how to deploy the service using GKE, provided that you have some knowledge of k8s and can simply use the kubectl command.

1. Install and configure Google Cloud SDK

Google Cloud SDK is a command-line tool set that accesses various resources of GCP (Google Cloud Platform) platform, similar to aws's aws command-line tool.

There is no need to say much about installation and configuration. Click the link below to select the tar package for the corresponding operating system version, then decompress it, and add google-cloud-sdk/bin to the PATH environment variable.

two。 Initialize Google Cloud SDK

Initializing Google Cloud SDK binds the gcloud command to the Google account and sets some other default values, such as regions, agents, accounts, projects (new projects in the Google account), and so on.

Before performing gcloud init initialization, you have to configure the HTTP proxy for gcloud (GFW you know), as shown in my previous article. Then execute gcloud init to complete the initialization and follow the wizard directly.

3. Set up a k8s cluster in the Google Cloud Platform console and remember the name

First acquaintance Google Kubernetes Engine (GKE) first acquaintance Google Kubernetes Engine (GKE) 4. Install the gcloud kubectl component gcloud components install kubectl5. Get the authentication credentials for the cluster

After you create the cluster, you need to obtain authentication credentials to interact with the cluster. To authenticate for the cluster, run the following command:

Gcloud container clusters get-credentials6. Next, deploy a simple hello-server service to GKEkubectl run hello-server-- image gcr.io/google-samples/hello-app:1.0-- port 8080 related links https://cloud.google.com/kubernetes-engine/docs/quickstarthttps://cloud.google.com/sdk/docs/quickstart-macos?hl=zh-cn Appendix gloud Common commands gcloud auth login-- no-launch-browser # gcloud login authentication gcloud config set compute/zone [COMPUTE_ZONE] # Set default area gcloud components list # list installable components gcloud components install [component name] # install component gcloud components update # Update all installed components gcloud components remove [component name] # Uninstall installed components Settings gcloud http Agent gcloud config set proxy/type httpgcloud config set proxy/address 127.0.0.1gcloud config set proxy/port 1087 Settings Cluster docker Private Service Certification kubectl create secret docker-registry regcred-- docker- Server=-docker-username=-docker-password=-docker-email=

Note: after setting up the docker private server, to deploy the K8s service in GKE, you must specify the imagePullSecrets key at the same level of container in the k8s resource file (yaml format), otherwise the image of the configured private server cannot be pulled. The example resource file is as follows:

ApiVersion: v1kind: Podmetadata: name: private-regspec: containers:-name: private-reg-container image:-name: regcred View the cluster docker private server configuration kubectl get secret regcred-- output=yaml # base64 format shows kubectl get secret regcred-- output= "jsonpath= {.data.\ .dockerconfigjson}" | base64-d # base64 above is all the content of the article "how to use GKE". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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

Development

Wechat

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

12
Report