“工欲善其事,必先利其器”。作为PaaS平台架构师,容器相关的技术(docker、k8s等)必不可少。本文简单介绍一下我自己的Linux操作系统配置。提高工作效率,改善用户体验。注:本文以CentOS7.6为例,RHEL7.6的操作类似。Ubuntu系统的运行可以绕过。这并不难。另外,下面还会有一些“可选”项,主要针对一些特殊情况,比如:需要通过代理上网...更换OS软件安装源目的:加快软件下载速度。可以换成:阿里、腾讯、清华、中科大....以清华镜像为例,操作步骤如下:参考文章:清华开源软件镜像站-CentOS镜像使用帮助https://mirrors.tuna.tsinghua...操作步骤先备份CentOS-Base.reposudocp/etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.bak用以下内容覆盖CentOS-Base.repo#CentOS-Base.repo##镜像系统使用客户端的连接IP地址和每个镜像的#updatestatus来挑选更新到和#地理位置靠近客户。你应该将它用于CentOS更新#,除非你手动选择其他镜像。##如果mirrorlist=不适合你,作为后备,你可以试试#remarkedoutbaseurl=行。##[base]name=CentOS-$releasever-Basebaseurl=https://mirrors.tuna。tsinghua.edu.cn/centos/$releasever/os/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=osenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7#releasedupdates[updates]name=CentOS-$releasever-Updatesbaseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updatesenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7#additionalpackagesthatmaybeuseful[extras]]name=CentOS-$releasever-Extrasbaseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extrasenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7#扩展现有组件功能的附加组件[centosplus]name=CentOS-$releasever-Plusbaseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplusgpgcheck=1enabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7更新软件包存储sudoyummakecache配置代理(可选)sudovi/etc/profile.d/setproxy.sh#!/bin/sh#forterminalexportproxyserveraddr=127.0.0.1exportproxyserverport=8080exportHTTP_PROXY="http://$proxyserveraddr:$proxyserverport/"exportHTTPS_PROXY="http://$proxyserveraddr:$proxyserverport/"#exportFTP_PROXY="ftp://$proxyserveraddr:$proxyserverport/"#exportSOCKS_PROXY="socks://$proxyserveraddr:$proxyserverport/"exportNO_PROXY="localhost,127.0.0.1,localaddress,.localdomain.com"exporthttp_proxy="http://$proxyserveraddr:$proxyserverport/"exporthttps_proxy="http://$proxyserveraddr:$proxyserverport/"#exportftp_proxy="ftp://$proxyserveraddr:$proxyserverport/"#exportsocks_proxy="socks://$proxyserveraddr:$proxyserverport/"exportno_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"sudosource/etc/profile.d/setproxy.shYUM配置代理echo"proxy=http://127.0.0.1:8080》>>/etc/yum.conf安装配置Git目的:要使用Git,毕竟很多资料、代码库和软件都需要通过gitclone步骤配置全局用户sudoyuminstall-ygit:gitconfig--globaluser.name""配置全局邮箱:gitconfig--globaluser.email""(可选):配置ssh认证参考文档:GitHub-使用SSH连接到GitHubhttps://docs.github.com/cn/gi...(optional):配置代理Proxy#查看当前代理设置gitconfig--globalhttp.proxy#设置当前代理为http://127.0.0.1::8080或socket5://127.0.0.1::8080gitconfig--globalhttp.proxy'http://127.0.0.1::8080'gitconfig--globalhttps.proxy'http://127.0.0.1::8080'gitconfig--globalhttp.proxy'socks5://127.0.0.1::8080'gitconfig--globalhttps.proxy'socks5://127.0.0.1::8080'#删除代理gitconfig--global--unsethttp.proxygitconfig--global--unsethttps.proxy(可选):配置代理绕过,如origin对应仓库需要绕过:gitconfig--addremote.origin.proxy""优化配置Shell目的:zsh+plugins,提供丰富友好的shell体验。如:语法高亮、自动补全、自动Suggestion、容器相关插件...安装zshsudoyuminstall-yzshzsh--versionsudochsh-s$(whichzsh)#logoutandinstallpowerline可以安装通过pip:pipinstallpowerline-status参考文章:powerline-安装:https://powerline.readthedocs...installoh-my-zshsh-c"$(wgethttps://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh-O-)”注意:如果无法连接:,从github对应的地址复制脚本:https://github。com/ohmyzsh/oh...并安装zsh插件:zsh-autosuggestions和zsh-syntax-highlighting参考文档:zsh-syntax-highlightingINSTALL.md:https://github.com/zsh-users/...zsh-syntax-highlighting克隆:gitclonehttps://github.com/zsh-users/zsh-syntax-highlighting.git${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting在~/.zshrc中激活插件:plugins=([plugins...]zsh-syntax-highlighting)restartzshzsh-autosuggestionsclone:gitclonehttps://github.com/zsh-users/zsh-autosuggestions${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions激活~/.zshrc中的插件:plugins=([plugins...]zsh-autosuggestions)重启zsh并使用oh-my-zsh编辑zshrc文件:vi~/.zshrc#ModifythemeZSH_THEME="agnoster"#Enablepluginplugins=(gitansibledocker-composedockerhelmkubectlminikubeocpippythonubuntuzsh-autosuggestionszsh-syntax-highlighting)备注:helm:k8s上的镜像包管理工具minikube:最小化K8S安装工具oc:K8SRedHat商业发行版(OpenShift)命令行工具最终效果按需安装常用软件用途:根据自己的需要,按需安装常用的软件和工具sudoyum-yinstalldnsmasqhttpdhaproxynginx\python3\genisoimagelibguestfs-tools按需配置服务并开机自启动:systemctlenablehaproxy.servicesystemctl启动haproxy.service。..安装jq,jq安装链接https://stedolan.github.io/jq....JQ是一个json格式的命令行工具,在K8S的日常管理中非常有用。建议直接安装容器组件docker全家桶Docker全家桶,省心省力参考文档:CentOS上安装DockerEngine:https://docs.docker.com/engin...卸载旧版本:$sudoyum删除docker\docker-client\docker-client-latest\docker-common\docker-latest\docker-latest-logrotate\docker-logrotate\docker-engine配置REPOSITORY$sudoyuminstall-yyum-utils$sudoyum-config-manager\--添加回购\https://download.docker.com/linux/centos/docker-ce.repo安装:$sudoyuminstalldocker-cedocker-ce-clicontainerd.iostart:$sudosystemctlstartdockerverify:$sudodockerrunhello-world其他开源组件对于RedHat系统,可能需要安装多个组件来代替:sudoyum-yinstallbuildahpodmanskopeo备注:buildah:构建容器镜像的组件podman:运行容器镜像的组件skopeo:transport和移动容器镜像组件安装Kubectl官方安装文档:https://kubernetes.io/zh/docs...下载:curl-LO》https://storage.googleapis.com/kubernetes-release/release/$(curl-shttps://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl》将kubectl文件标记为可执行:chmod+x./kubectl把文件放在PATH下路径:sudomv./kubectl/usr/local/bin/kubectl测试你安装的版本是否是最新的:kubectlversion--clientinstallminikubeorkind这里以minikube为例:官方安装文档:https://kubernetes.io/zh/docs...需要强调的是:阅读中文文档说明:因为国内不能直接连接到k8s。gcr.io,推荐使用阿里云镜像仓库,在minikubestart中加上--image-repository参数。示例:minikubestart--vm-driver=--image-repository=registry.cn-hangzhou.aliyuncs.com/google_containersinstallhelmv3binaryCLI下载地址https://github.com/helm/helm/...安装源文档:https://helm.sh/docs/intro/in...$curl-fsSL-oget_helm.shhttps://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3$chmod700get_helm.sh$./get_helm.shinstallOpenShift命令行oc直接下载二进制CLI安装:https://mirror.openshift.com/...installOpenShiftforDeveloper命令行odo直接下载BinaryCLI安装:https://mirror.openshift.com/...安装Tekton-K8S原生CI/CD工具CLI工具叫tkn,官方文档:https://github.com/tektoncd/cli安装:#获取tar.xzcurl-LOhttps://github.com/tektoncd/cli/releases/download/v0.12.0/tkn_0.12.0_Darwin_x86_64.tar.gz#将tkn提取到您的路径(例如/usr/local/bin)sudotarxvzftkn_0.12.0_Darwin_x86_64.tar.gz-C/usr/local/bintkn当然golang环境也是必不可少的。最后祝大家一切顺利!