Best Practices
Total Page:16
File Type:pdf, Size:1020Kb
Cloud Container Engine Best Practices Issue 01 Date 2021-09-07 HUAWEI TECHNOLOGIES CO., LTD. Copyright © Huawei Technologies Co., Ltd. 2021. All rights reserved. No part of this document may be reproduced or transmitted in any form or by any means without prior written consent of Huawei Technologies Co., Ltd. Trademarks and Permissions and other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd. All other trademarks and trade names mentioned in this document are the property of their respective holders. Notice The purchased products, services and features are stipulated by the contract made between Huawei and the customer. All or part of the products, services and features described in this document may not be within the purchase scope or the usage scope. Unless otherwise specified in the contract, all statements, information, and recommendations in this document are provided "AS IS" without warranties, guarantees or representations of any kind, either express or implied. The information in this document is subject to change without notice. Every effort has been made in the preparation of this document to ensure accuracy of the contents, but all statements, information, and recommendations in this document do not constitute a warranty of any kind, express or implied. Issue 01 (2021-09-07) Copyright © Huawei Technologies Co., Ltd. i Cloud Container Engine Best Practices Contents Contents 1 Checklist for Deploying Containerized Applications in the Cloud...............................1 2 Cluster........................................................................................................................................ 9 2.1 Creating an IPv4/IPv6 Dual-Stack Cluster in CCE........................................................................................................ 9 2.2 Implementing High Availability for Containers in CCE............................................................................................18 2.3 Using a Private Image to Build a Worker Node Image........................................................................................... 22 2.4 Adding a Salt in the password Field When Creating a Node................................................................................ 26 2.5 Adding a Second Data Disk to a Node in a CCE Cluster.........................................................................................29 2.6 Cleaning Up CCE Resources on a Deleted Node........................................................................................................30 2.7 Changing the Mode of the Docker Device Mapper.................................................................................................. 32 2.8 Connecting to Multiple Clusters Using kubectl.......................................................................................................... 37 2.9 Interconnecting CCE with Helm.......................................................................................................................................43 3 Networking............................................................................................................................. 47 3.1 Selecting a Network Model When Creating a Cluster on CCE..............................................................................47 3.2 Planning CIDR Blocks for a CCE Cluster........................................................................................................................50 3.3 Configuring Containers to Access Public Networks.................................................................................................. 56 3.4 Implementing Sticky Session Through Load Balancing...........................................................................................60 3.5 Connecting Two VPCs Across Regions Through a VPN (VPC Router Networking)........................................66 3.6 Allowing Nodes Outside a Cluster in the Same VPC to Access the Pod IP Addresses in the Cluster...... 71 3.7 Enabling a CCE Cluster to Resolve Domain Names on Both On-Premises IDCs and HUAWEI CLOUD ............................................................................................................................................................................................................ 77 3.7.1 Solution Overview............................................................................................................................................................. 77 3.7.2 Solution 1: Using a DNS Endpoint for Cascading Resolution............................................................................ 80 3.7.3 Solution 2: Changing the CoreDNS Configurations...............................................................................................83 3.8 Allowing Containers and IDCs to Communicate with Each Other Through VPC and Direct Connect....86 3.9 Obtaining the Client Source IP Address for a Container......................................................................................... 89 3.10 Increasing the Listening Queue Length by Configuring Container Kernel Parameters............................. 94 3.11 Using Multiple ENIs on a Node in a CCE Cluster.................................................................................................... 98 3.12 Enabling Passthrough Networking for LoadBalancer Services........................................................................... 99 4 Storage...................................................................................................................................104 4.1 Expanding the Disk Capacity of a Node in a CCE Cluster.................................................................................... 104 4.2 Mounting an Object Storage Bucket of a Third-Party Tenant............................................................................ 105 4.3 Creating an SFS Turbo Volume in the subpath Mode........................................................................................... 110 Issue 01 (2021-09-07) Copyright © Huawei Technologies Co., Ltd. ii Cloud Container Engine Best Practices Contents 4.4 How Do I Change the Storage Class Used by a Cluster of v1.15 from FlexVolume to CSI Everest?..... 114 4.5 Upgrading s3fs of Nodes in a CCE Cluster (CentOS 7.6)......................................................................................126 4.6 Using OBS Parallel File Systems.................................................................................................................................... 129 4.7 Custom Storage Classes................................................................................................................................................... 130 5 Container...............................................................................................................................136 5.1 Properly Allocating Container Computing Resources............................................................................................ 136 5.2 Upgrading Pods Without Interrupting Services....................................................................................................... 138 5.3 Modifying Kernel Parameters Using a Privileged Container............................................................................... 140 5.4 Initializing a Container..................................................................................................................................................... 142 5.5 Setting Time Zone Synchronization............................................................................................................................. 143 5.6 Performing Graceful Deletion........................................................................................................................................ 147 5.7 Setting the Container Network Bandwidth Limit....................................................................................................148 5.8 Using kubectl to Modify hostAliases to Configure Container Parameters..................................................... 150 5.9 Configuring Domain Name Resolution for CCE Containers................................................................................ 152 5.10 How Do I Select a Container Runtime?....................................................................................................................158 6 Permission.............................................................................................................................162 6.1 Configuring kubeconfig for Fine-Grained Management on Cluster Resources............................................ 162 6.2 Performing Cluster Namespace RBAC.........................................................................................................................166 7 Monitoring............................................................................................................................ 171 7.1 Connecting a CCE Cluster to Heapster for Monitoring......................................................................................... 171 8 Auto Scaling......................................................................................................................... 175 8.1 Using HPA and CA for Auto Scaling of Workloads and Nodes.......................................................................... 175 8.2 Auto Scaling Based on ELB Monitoring Metrics.....................................................................................................