说句闲话:这本是一篇笔记,本来没想发出来,但是突然有道云这个坑货,将另一篇笔记的内容完全覆盖了这一篇。这种情况以前也出现过,一般重开一次就好了,然而这次却不好使,开chrome隐私模式登录看到也是被覆盖的,当时我就慌了……好在哥们急中生智,将手机断网打开有道云笔记,看到了熟悉的内容,于是全部复制出来才得以保全此文。后面计划陆续把笔记同步过来以防万一,就是给隐私打码也挺麻烦的……
systemctl stop iptables
systemctl stop firewalld
vi /etc/selinux/config
SELINUX=disabled
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install -y docker-ce
echo '{"insecure-registries":["harbor.t2cp.com"]}' >> /etc/docker/daemon.json
service docker start
curl -o go1.13.linux-amd64.tar.gz https://dl.google.com/go/go1.13.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.13.linux-amd64.tar.gz
创建工作目录
mkdir -p ~/go/src ~/go/pkg ~/go/bin
编辑/etc/profile
添加如下
# golang
export PATH=$PATH:/usr/local/go/bin
export PATH=$PATH:~/go/bin
echo "# golang" >> /etc/environment
echo "PATH=$PATH:/usr/local/go/bin" >> /etc/environment
echo "PATH=$PATH:~/go/bin" >> /etc/environment
source /etc/profile
go env -w GOPROXY="https://goproxy.cn,direct"
go get github.com/go-delve/delve
cd ~/go/src/github.com/go-delve/delve/cmd/dlv/
go install
yum install -y git
mkdir -p ~/go/src/github.com/rancher
cd ~/go/src/github.com/rancher
git clone ...
git checkout ...
Tools->Deployment->Configuration
点+
选SFTP
后输入名称(随意),然后Host为IP,然后是登录信息(用户名密码)
然后RootPath是远程代码的绝对路径
Mappings中的DeploymentPath填/
ctrl+shift+a
->edit configurations
点+
选go remote
后填入名称(随意)和远程IP
到主机上执行
cd ~/go/src/github.com/rancher/rancher/
dlv debug --build-flags "-tags "k8s"" --headless --listen=:2345 --api-version=2 --accept-multiclient
dlv debug --build-flags "-tags "k8s"" --headless --listen=:2345 --api-version=2 --accept-multiclient -- --http-listen-port=8080 --https-listen-port=8443 --audit-log-path=${AUDIT_LOG_PATH} --audit-level=${AUDIT_LEVEL} --audit-log-maxage=${AUDIT_LOG_MAXAGE} --audit-log-maxbackup=${AUDIT_LOG_MAXBACKUP} --audit-log-maxsize=${AUDIT_LOG_MAXSIZE} "${@}"
等输出API server listening at: [::]:2345
后到goland上shift+F9
此时主机上会有log输出,一段时间后搜一下8443
如果看到[INFO] Listening on :8443
就可以postman访问了
echo '*** ***' >> /etc/hosts
docker run -itd --privileged --entrypoint '/bin/bash' -p 8080:8080 -p 8443:8443 -p 30080:80 -p 30443:443 -p 2345:2345 -p 8022:22 ***/library/rancher/rancher:v2.2.2m114-dev
容器中
# 只启动rancher-server
/usr/bin/rancher
# 启动rancher前后端
/usr/bin/rancher --http-listen-port=8080 --https-listen-port=8443 --audit-log-path=${AUDIT_LOG_PATH} --audit-level=${AUDIT_LEVEL} --audit-log-maxage=${AUDIT_LOG_MAXAGE} --audit-log-maxbackup=${AUDIT_LOG_MAXBACKUP} --audit-log-maxsize=${AUDIT_LOG_MAXSIZE} "${@}"
# apt update
apt update
# ssh
apt install --fix-missing -y openssh-server
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
/bin/echo 'root:***' |chpasswd
service ssh restart
# gcc
apt install --fix-missing -y gcc
https://github.com/rancher/ui
curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
sudo yum install -y nodejs
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum -y install yarn
mkdir ~/rancher-ui
git clone 'https://github.com/rancher/ui'
cd 'ui'
./scripts/update-dependencies
RANCHER="https://localhost:8443" yarn start
https://localhost:8000/
FROM ***/library/rancher/rancher:***
# install ssh & gcc
RUN apt update && \
apt install --fix-missing -y openssh-server && \
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config && \
/bin/echo 'root:***' |chpasswd && \
service ssh restart && \
apt install --fix-missing -y gcc
ENV PATH=/go/bin:/usr/local/go/bin:${PATH}
# install go & dlv
RUN curl -o go1.13.linux-amd64.tar.gz https://dl.google.com/go/go1.13.linux-amd64.tar.gz && \
tar -C /usr/local -xzf go1.13.linux-amd64.tar.gz && \
rm -f go1.13.linux-amd64.tar.gz && \
mkdir -p /go/src /go/pkg /go/bin && \
go env -w GOPROXY="https://goproxy.cn,direct" && \
go env -w GOPATH="/go" && \
go get -u github.com/go-delve/delve/cmd/dlv && \
go install /go/src/github.com/go-delve/delve/cmd/dlv/ && \
mkdir -p /go/src/github.com/rancher
WORKDIR /go/src/github.com/rancher
ENTRYPOINT ["/bin/bash"]
docker run --name tmp4 -itd --privileged --entrypoint '/bin/bash' -p 8080:8080 -p 8443:8443 -p 30080:80 -p 30443:443 -p 2345:2345 -p 8022:22 harbor.t2cp.com/library/rancher/rancher-env-for-develop:1.1