Recommendations for optimizing Linux operating machine configurations for container DevOps personnel
This article was last updated on: July 24, 2024 am
AS A PAAS PLATFORM ARCHITECT, CONTAINER-RELATED TECHNOLOGIES (DOCKER, K8S, ETC.) ARE ESSENTIAL. This article briefly introduces my own Linux operating machine configuration. Improve work efficiency and improve user experience. ❤❤❤
❗ Note:
This article uses CentOS 7.6 as an example, RHEL7.6 operation is similar.
Ubuntu system operation can be bypassed. It’s not difficult.
In addition, there will be some “optional” items in the following, mainly for some special cases, such as: Need to connect to the Internet through a proxy…
Replace the OS software installation source
Purpose: Speed up software downloads.
Can be replaced with: Ali, Tencent, Tsinghua, University of Science and Technology of China… of sources.
Taking Tsinghua Mirror as an example, the operation steps are as follows:
🔖 Reference article:
Tsinghua University Open Source Software Image Site - CentOS Image Usage Helphttps://mirrors.tuna.tsinghua.edu.cn/help/centos/
Procedure
-
Back up CentOS-Base.repo first
1
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
-
Cover with the following
CentOS-Base.repo
# CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7 #released updates [updates] name=CentOS-$releasever - Updates baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7
-
Update the package cache
1
sudo yum makecache
Configure the agent (optional)
sudo vi /etc/profile.d/setproxy.sh
1 |
|
sudo source /etc/profile.d/setproxy.sh
YUM configures the proxy
1 |
|
Install and configure Git
Purpose: To use Git, after all, a lot of data, codebase, and software need to passgit clone
steps
-
sudo yum install -y git
-
To configure global users:
git config --global user.name "<username>"
-
Configure global email:
git config --global user.email "<[email protected]>"
-
(Optional): Configure SSH authentication
- 🔖 Reference documentation: GitHub - Connect to GitHub using SSH https://docs.github.com/cn/github/authenticating-to-github/connecting-to-github-with-ssh
-
(Optional): Configure proxy proxy
1
2
3
4
5
6
7
8
9
10
11
12# 查看当前代理设置
git config --global http.proxy
# 设置当前代理为 http://127.0.0.1::8080 或 socket5://127.0.0.1::8080
git config --global http.proxy 'http://127.0.0.1::8080'
git config --global https.proxy 'http://127.0.0.1::8080'
git config --global http.proxy 'socks5://127.0.0.1::8080'
git config --global https.proxy 'socks5://127.0.0.1::8080'
# 删除 proxy
git config --global --unset http.proxy
git config --global --unset https.proxy -
(Optional): Configure Proxy Bypass, if the origin of the corresponding repository requires Bypass:
git config --add remote.origin.proxy ""
Optimize the configuration of the shell
Purpose: zsh + plugins, to provide a rich and friendly shell experience. Such as: syntax highlighting, auto-completion, auto-suggestions, container related plugins…
Install zsh
sudo yum install -y zsh
zsh --version
sudo chsh -s $(which zsh)
# 注销
Install Powerline
Can passpip
Installation:
1 |
|
🔖 Reference article:
powerline - Installation: https://powerline.readthedocs.io/en/latest/installation.html#pip-installation
Install oh-my-zsh
1 |
|
⚠ Note:
If you can’t connect: <raw.githubusercontent.com>, take the corresponding address from GitHub: https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/install.shCopy the script and run it.
Install the zsh plugin: zsh-autosuggestions
and zsh-syntax-highlighting
🔖 Reference documentation:
- zsh-syntax-highlighting INSTALL.md: https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/INSTALL.md
zsh-syntax-highlighting
- clone:
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
- at
~/.zshrc
To activate the plugin:plugins=( [plugins...] zsh-syntax-highlighting)
- Restart zsh
zsh-autosuggestions
- clone:
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
- at
~/.zshrc
To activate the plugin:plugins=( [plugins...] zsh-autosuggestions)
- Restart zsh
Use oh-my-zsh
Edit the zshrc file: vi ~/.zshrc
1 |
|
📓 Note:
- Helm: Image package management tool on k8s
- minikube: Minimal K8S installation tool
- oc: A command-line tool for the commercial distribution of RedHat (OpenShift) for K8S
The final effect
Install frequently used software on demand
Purpose: Install common software and tools as needed according to your needs
1 |
|
Configure services on demand and power on:
1 |
|
Install jq, jq installation linkhttps://stedolan.github.io/jq/download/. JQ is a json formatting command line tool that is useful for day-to-day management of K8S.
Install the container class components
Docker family bucket
It is recommended to install the docker family bucket directly, saving worry and effort
🔖 Reference documentation:
Install Docker Engine on CentOS: https://docs.docker.com/engine/install/centos/
-
Uninstall the old version:
1
2
3
4
5
6
7
8$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine -
CONFIGURE THE REPOSITORY
1
2
3
4
5$ sudo yum install -y yum-utils
$ sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo -
Installation:
1
$ sudo yum install docker-ce docker-ce-cli containerd.io
-
Initiate:
1
$ sudo systemctl start docker
-
Verify:
1
$ sudo docker run hello-world
Other open source components
For RedHat series, multiple component replacements may be installed:
1 |
|
📓 Note:
- buildah: The component that builds the container image
- podman: The component that runs the container image
- skopeo: Transports components that move container images
Installation kubectl
Official installation documentation: https://kubernetes.io/zh/docs/tasks/tools/install-kubectl/
- Download:
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
- mark
kubectl
The file is executable:chmod +x ./kubectl
- Place the file under the PATH path:
sudo mv ./kubectl /usr/local/bin/kubectl
- Test that the version you installed is up to date:
kubectl version --client
Install MiniKube or Kind
Here is the example of minikube:
Official installation documentation: https://kubernetes.io/zh/docs/tasks/tools/install-minikube/
⚠ It should be emphasized that:
- See Chinese documentation
- 📓 Note: Since you cannot directly connect to k8s.gcr.io in China, it is recommended to use Alibaba Cloud image repository
minikube start
added--image-repository
Parameter. - Example:
minikube start --vm-driver=<驱动名称> --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers
Install helm v3
Binary CLI download addresshttps://github.com/helm/helm/releases/latest
Installation source documentation: https://helm.sh/docs/intro/install/
1 |
|
Install the OpenShift command line oc
Download the binary CLI installation directly: https://mirror.openshift.com/pub/openshift-v4/clients/oc/
Install the OpenShift for Developer command lineodo
Download the binary CLI installation directly:https://mirror.openshift.com/pub/openshift-v4/clients/odo/latest/
Install Tekton - K8S native CI/CD tool
The CLI tool is calledtkn
, Official Documentation: https://github.com/tektoncd/cli
Installation:
1 |
|
finish
Of course golang
The environment is also essential.
Finally, I wish you all the best of luck! 💪💪💪