Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Cloud Container Engine/ Best Practices/ Cluster/ Using OBS Buckets to Implement Custom Script Injection During Node Creation

Using OBS Buckets to Implement Custom Script Injection During Node Creation

Updated on 2024-12-28 GMT+08:00

Background

If you need to install some tools or perform custom security hardening on a node in advance, you need to inject some scripts when creating the node. CCE allows you to inject pre-installation and post-installation scripts when creating a node. However, this function has the following restrictions:

  • The script characters are limited.
  • The injected script content needs be frequently modified to meet various requirements and scenarios. However, CCE node pools have fixed scripts and do not support frequent modifications.

Solution

This section provides a simplified, scalable, easy-to-maintain best practice that combines CCE and OBS. It enables custom operations on CCE nodes.

The pre-installation and post-installation scripts are stored in an OBS bucket. When creating a node pool, the scripts directly retrieve the address of the corresponding OBS script and execute it. This approach eliminates the need to modify the configuration of the CCE node pool. If there are any new requirements, you can simply update the scripts in the OBS bucket.

Suggestions on Maintaining OBS Buckets

  • If there is no OBS bucket dedicated for O&M, create an OBS bucket dedicated for O&M.
  • Create a multi-level directory tools/cce in the bucket to represent CCE-specific tools for easy maintenance. You can also store other tool scripts in this directory later.

Precautions

  • If the custom operation implemented by the script fails, the normal service running is affected. You are advised to add a check program at the end of the script. If the check fails, stop the kubelet process in the post-installation script to prevent services from being scheduled to the node.
    systemctl stop kubelet-monit
    systemctl stop kubelet
  • Do not include sensitive information in the scripts to prevent information leakage.

Procedure

  1. Create an OBS bucket.
  2. Upload the pre-installation and post-installation scripts. The pre_install.sh and post_install.sh scripts are used as examples.

    Figure 1 Uploading scripts

  3. Configure a read-only security policy for the scripts to ensure that the scripts can be downloaded without entering a password on the CCE nodes but cannot be downloaded from the Internet.

    1. Configure a policy for the tools/cce directory and select a read-only policy template.
      Figure 2 Configuring an object policy
    2. Modify the configuration information about the anonymous user, specified objects, and conditions.
      Figure 3 Anonymous user
      Figure 4 Specified objects
      Figure 5 Conditions
      Two conditions are set: UserAgent and SourceIp.
      • UserAgent functions in the similar way as a key. The specified User-Agent request header and the corresponding key value must be carried during access.
      • SourceIp is used to prevent access from external networks. Set this parameter to 100.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,214.0.0.0/8, among which 100.0.0.0/8 and 214.0.0.0/8 are private IP ranges, among whom 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16 are commonly used.

      For details about how to configure an OBS policy, see Configuring an Object Policy and Bucket Policy Parameters.

  4. Configure the pre-installation script and post-installation script when creating a node pool on CCE.

    Enter the following scripts in the Advanced ECS Settings on the Create Node Pool page:

    In the scripts below, the curl command is run to download pre_install.sh and post_install.sh from OBS to the /tmp directory, and then pre_install.sh and post_install.sh are executed.

    Pre-installation script:

    curl -H "User-Agent: ccePrePostInstall" https://ops-cce.obs.ap-southeast-1.myhuaweicloud.com/tools/cce/pre_install.sh -o  /tmp/pre_install.sh && bash -x /tmp/pre_install.sh > /tmp/pre_install.log 2>&1

    Post-installation script:

    curl -H "User-Agent: ccePrePostInstall" https://ops-cce.obs.ap-southeast-1.myhuaweicloud.com/tools/cce/post_install.sh -o  /tmp/post_install.sh && bash -x /tmp/post_install.sh > /tmp/post_install.log 2>&1
    NOTE:
    • The actual value of User-Agent must be configured based on the OBS bucket policy.
    • The bucket address in the link must be configured based on site requirements.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback