Author’s brief introduction
Hailong Wang, Rancher China Community Technology Manager, is responsible for the maintenance and operation of Rancher China Technology Community. I have 7 years of experience in cloud computing and experienced the technical transformation from OpenStack to Kubernetes. I have rich practical experience in operation and peacekeeping no matter the underlying operating system Linux, virtual KVM or Docker container technology.
preface
Recently, I’ve been getting questions from the community about how to modify parameters like Kube-API and Kubelet. Kube-apiserver, kube-controller-manager, kubelet, kube-scheduler, kube-proxy, etcd How to modify the parameters of the Kubernetes service in Rancher
How to modify Kubernetes service parameters in Rancher
Rancher created a custom cluster, in fact, through RKE deployment Kubernetes cluster, so whether through Rancher UI to create a custom cluster, or through RKE to start Kubernetes cluster, You can refer to the example cluster.yml file to set corresponding parameters. The cluster.yml file contains some common Kubernetes Service configuration items, such as NodePort port range, Service IP CIDR, etc. To modify these parameters, we only need to modify the values of the parameters:
kube-api: # IP range for any services created on Kubernetes # This must match the service_cluster_ip_range in kube-controller # Expose a different port range for NodePort services service_node_port_range: 30000-32767... .Copy the code
If the built-in parameter options do not contain the Kubernetes service parameters you want to modify, we can add the corresponding Kubernetes parameter options to the Extra_args of each Kubernetes service: For example, modify kube-Apiserver NodePort range and enable RemoveSelfLink:
kube-api: extra_args: Parameters in the extra_ARgs have a higher priority than the rKE default. So “service-node-port-range” overwrites the value of “service_node_port_range” service-node-port-range: 40000-42767 feature-gates: ‘RemoveSelfLink=false’
How to modify the Kubernetes service parameters of a custom cluster in Rancher? We can select the cluster in Rancher UI and click on the right side. Then click Edit to go to the Edit cluster page:
Then, click Edit as YAML:
Rancher_kubernetes_engine_config. services: kubernetes_engine_config.services
Finally, click Save to Save the modified parameter configuration. If the configuration format is correct, Rancher automatically updates the downstream Kubernetes cluster.
Principles for modifying Kubernetes service parameters in Rancher
All kubernetes services are modified at the rancher_kubernetes_engine_config.services level, e.g. Kube-apiserver parameter level:
rancher_kubernetes_engine_config:
services:
kube-api: {}
Copy the code
Kube-controller-manager parameter hierarchy:
rancher_kubernetes_engine_config:
services:
kube-controller: {}
Copy the code
The default YAML parameter names are separated by -, while Kubernetes service parameter names are separated by _. For example, when editing a cluster using YAML, the default parameter names are:
service-node-port-range: 40000-42767
Copy the code
Kubernetes service API parameter naming rules:
service_node_port_range: 30000-32767
Copy the code
You can add additional Kubernetes service parameters to extra_args:, but you need to remove the — before each parameter. For example, the parameter of enabling SelfLink in Kube-Apiserver is –feature-gates=RemoveSelfLink=false, and the parameter format added in Rancher YAML should be as follows:
rancher_kubernetes_engine_config:
services:
kube-api:
extra_args:
feature-gates: 'RemoveSelfLink=false'
Copy the code
Parameters in extra_args have higher priorities than RKE’s default values, so service-node-port-range overrides the value of the service_node_port_range parameter.
rancher_kubernetes_engine_config: services: kube-api: service_node_port_range: 30000-32767 extra_args: Parameters in the extra_ARgs have a higher priority than the rKE default. So "service-node-port-range" overwrites the value of the "service_node_port_range" parameter service-node-port-range: 40000-42767Copy the code
How do I check whether a parameter takes effect
If you can successfully save and update the cluster after the modification, your parameter format is correct. So, how do you confirm that the modified parameters have taken effect? We can log in to the corresponding node, and then check the Args of the corresponding Kubernetes service through Docker inspect:
# docker inspect kube-apiserver "Args": [··· "--service-node-port-range=40000-42767", "--feature-gates=RemoveSelfLink=false", ···],Copy the code
reference
- RKE cluster parameters: the docs. The rancher. Cn/docs/ranche…
- RKE cluster. Yml file example: docs. The rancher. Cn/docs/RKE/ex…