In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to use kops to install k8s in AWS China, I believe most people do not know much about it, so share this article for your reference. I hope you will learn a lot after reading this article. Let's learn about it together.
Install kops (Binaries)
We recommend using a low-configuration server as the management machine for K8s and installing management tools such as kops on it.
Download compiled binaries from github
Wget-O kops https://github.com/kubernetes/kops/releases/download/$(curl-s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut-d'"'- f 4) / kops-linux-amd64chmod + x. / kopssudo mv. / kops / usr/local/bin/ install other dependent kubectl
Kubectl is a CLI tool for managing and operating Kubernetes clusters.
Obtain the release version from Kubernetes official kubectl:
Wget-O kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl-s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectlchmod + x. / kubectlsudo mv. / kubectl / usr/local/bin/kubectl install the AWS CLI tool
Awscli is written in Python. After installing Python and pip, just run the following command.
Pip install awscli creates an account
Prior to version 1.6.2, deploying a K8s cluster through kops required the use of AWS's Route53 to provide DNS service functionality. However, starting with version 1.6.2, kops supports the deployment of gossip-based clusters instead of relying on Route53, which makes deployment operations easier.
Configure the AWS account and use it to create a dedicated account for kops:
$aws configureAWS Access Key ID [None]: AWS Secret Access Key [None]: Default region name [None]: cn-north-1Default output format [None]: json
In order to deploy the cluster using kops, you also need to create an IAM user kops for kops and assign the appropriate permissions:
$aws iam create-group-group-name kops$ aws iam attach-group-policy-policy-arn arn:aws:iam::aws:policy/AmazonEC2FullAccess-group-name kops$ aws iam attach-group-policy-policy-arn arn:aws:iam::aws:policy/AmazonRoute53FullAccess-group-name kops$ aws iam attach-group-policy-policy-arn arn:aws:iam::aws:policy/AmazonS3FullAccess-group-name kops$ aws iam attach-group-policy-policy-arn arn:aws:iam: : aws:policy/IAMFullAccess-group-name kops$ aws iam attach-group-policy-policy-arn arn:aws:iam::aws:policy/AmazonVPCFullAccess-group-name kops$ aws iam create-user-user-name kops$ aws iam add-user-to-group-user-name kops-group-name kops
Create a key for the kops user:
$aws iam create-access-key-user-name kops
The above command returns the AccessKeyID and SecretAccessKey of the kops user. Then we can update the configuration of awscli to use the key of the newly created kops user:
$aws configureAWS Access Key ID [None]: AWS Secret Access Key [None]: Default region name [None]: cn-north-1Default output format [None]: json
You also need to export the kops user's key to the environment variable on the command line:
$export AWS_ACCESS_KEY_ID=$ (aws configure get aws_access_key_id) $export AWS_SECRET_ACCESS_KEY=$ (aws configure get aws_secret_access_key) $export AWS_REGION=$ (aws configure get region)
Finally, the SSH key is generated:
$ssh-keygen configuration S3
It should be noted that in order for kops to create a gossip-based cluster, the cluster needs to be named with .k8s.local as a suffix. For example, here we name the cluster cluster.k8s.local:
$export NAME=cluster.k8s.local
Then create a S3 bucket for users to store the data of the cluster. For example, here we name this bucket cluster.k8s.local-state.ym:
$aws s3api create-bucket--bucket ${NAME}-state-store-- create-bucket-configuration LocationConstraint=$AWS_REGION$ export KOPS_STATE_STORE=s3://cluster.k8s.local-state-store prepares kops ami
We have to build our own AMI because there is no official kops ami in AWS China.
Create a cluster
The following command creates a configuration file for the cluster and does not actually create the cluster:
Note: kops-1.8.1 does not support Ningxia District of China, only Beijing District
$kops create cluster\-- name=$ {NAME}\-- image=ami-089b06f993df09d53\-- zones=cn-north-1a\-- master-count=1\-master-size= "t2.micro"\-- node-count=1\-- node-size= "t2.micro"\-- vpc=\-- subnets=\-- networking=calico\-- ssh-public-key= "~ / .ssh/id_rsa.pub"
For the network model, calico is used because network planning is carried out on-line. When using the default kubenet of K8s, K8s modifies the AWS routing table, which means that K8s needs its own routing table and its own subnet. If the network has been planned in the production environment, the specified subnet,k8s network will not work properly.
Before creating a cluster, you can check that the configuration file of the cluster is correct:
$kops edit cluster ${NAME}
On AWS, we usually use our own key to connect to the server
... spec: sshKeyName:...
Because some websites are walled, it is recommended to use proxies to build clusters.
... spec: egressProxy: httpProxy: host: http-proxy port: port excludes: amazonaws.com.cn,amazonaws.cn,aliyun.cn,aliyuncs.com...
You can also specify a docker version
... spec: docker: logDriver: json-file version: 17.03.2 Murce.
If you confirm that there is no problem, you can create a cluster using the following command:
$kops update cluster ${NAME}-- yes
After creating a cluster, you need to wait for a period of time for the initialization of the cluster, and after waiting for the cluster to rise, you can verify the status of the cluster:
$kops validate cluster
Now that the kubectl tool has been installed, you can also use kubectl to check the cluster status:
$kubectl get nodes destroys the cluster
Before destroying the cluster, you need to confirm which resources will be deleted by kops:
$kops delete cluster-- name ${NAME}
If you confirm that there is no problem, you can actually delete the cluster:
$kops delete cluster-- name ${NAME}-- the above yes is all the contents of the article "how to install k8s using kops in AWS China". 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.