280篇 Default中的文章

git list CRLF line ending file in uncommited files

关于git的crlf提交有如下配置。

提交时转换为LF,检出时转换为CRLF
git config --global core.autocrlf true

提交时转换为LF,检出时不转换
git config --global core.autocrlf input

提交检出均不转换
git config --global core.autocrlf false

拒绝提交包含混合换行符的文件
git config --global core.safecrlf true

允许提交包含混合换行符的文件
git config --global core.safecrlf false

提交包含混合换行符的文件时给出警告
git config --global core.safecrlf warn

但是我本地采用了git config --global core.autocrlf input, 即提交和检出都不使用自动转换crlf。那么这个就需要保证自己提交文件时注意将换行改为LF。

git status -s|grep -v 'D '|awk '{print $2}'|xargs file|grep CRLF
这条命令是将未提交到本地的文件列出,排除已删除的,并且行结尾使用了CRLF的。

More ~

rpmbuild: '\r': command not found

RPM编译时遇到这个问题

xecuting(%build): /bin/sh -e /var/tmp/rpm-tmp.HDvAfF
+ umask 022
+ cd /tmp/csmp-build-TLlpXrJT/BUILD
+ cd csmp-2.0.3sp1
+ $'\r'
/var/tmp/rpm-tmp.HDvAfF: line 29: $'\r': command not found
error: Bad exit status from /var/tmp/rpm-tmp.HDvAfF (%build)


RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.HDvAfF (%build)
make: *** [rpm] Error 1
make: Leaving directory `/root/rpms/xxx'

打开这个文件/var/tmp/rpm-tmp.HDvAfF时,会看到29号有个特殊的字符 ^M

这个其实是CLRF 没转成LF的问题, linux上用yum install dos2unix,修改相应的文件 即 dos2unix filename 即可

More ~

git export ?(git 导出)

实际上没有git export的命令,有也可能是第三方的。
那么这里有个git archive可以用作导出。

git archive [--format=<fmt>] [--list] [--prefix=<prefix>/] [<extra>]
	      [-o <file> | --output=<file>] [--worktree-attributes]
	      [--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish>
	      [<path>…​]
More ~

Kubernetes 的Service和Deployment

找了段解释如下:

Kubernetes Service vs Deployment What's the difference between a
Service and a Deployment in Kubernetes?

A deployment is responsible for keeping a set of pods running.

A service is responsible for enabling network access to a set of pods.

We could use a deployment without a service to keep a set of identical
pods running in the Kubernetes cluster. The deployment could be scaled
up and down and pods could be replicated. Each pod could be accessed
individually via direct network requests (rather than abstracting them
behind a service), but keeping track of this for a lot of pods is
difficult.

We could also use a service without a deployment. We'd need to create
each pod individually (rather than "all-at-once" like a deployment).
Then our service could route network requests to those pods via
selecting them based on their labels.

直接翻译下就是:

depoyment负责保持一组Pod运行。
service负责启用对一组Pod的网络访问。

我们可以使用没有服务的部署来保持一组相同的Pod在Kubernetes集群中运行。 可以按比例放大和缩小部署,还可以复制Pod。 可以通过直接的网络请求(而不是将它们抽象到服务之后)分别访问每个Pod,但是要跟踪很多Pod很难。

我们也可以在没有部署的情况下使用服务。 我们需要分别创建每个Pod(而不是像部署那样“一次全部”创建)。 然后,我们的服务便可以根据标签的标签选择网络请求,将网络请求路由到这些Pod。

服务和部署是不同的,但是它们可以很好地协同工作。

换个方式理解就是:depoyment就是用容器镜像创的实例, service负责访问这些实例,可以将deployment的端口通过端口暴露给其它服务或外界网络。

More ~

Visit minikube dashboard in VM (访问虚拟内安装的minikube 后台)

上篇讲到在win10环境,vmware的虚拟机内安装minikube之后,发现在访问minikube dashboard是无法跳转的。

这里解决方法:

1 开启代理,虚拟机外可以通过 8081端口访问

kubectl proxy --address='0.0.0.0' --disable-filter=true

2 虚拟机通过如下地址访问

http://your_api_server_ip:8001/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/

your_api_server_ip 换成虚拟机的外部IP,如192.168.136.111

如果有开firewalld,可以通过firewall-cmd --zone=public --add-port=8081/tcp --permanent 添加例外,或直接关闭防火墙

More ~

windows环境使用CentOS7虚拟机安装minikube

in10环境,安装的VMware Workstation Pro,创建了一台Centos7.x的虚拟机。并启用虚拟化。
截图20191015175316721.jpg

先安装kubectl

// v1.16.0版本可以从这里查 https://storage.googleapis.com/kubernetes-release/release/stable.txt
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.16.0/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
kubectl version

上述如果在墙内,需要http代理可以,先将代理设为环境变量 export http_proxy=http://ip:port

也可以从github上下载
https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG.md#client-binaries-1
找到Current release如 https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG-1.16.md
再找到Client Binaries如v1.16.0下的 https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG-1.16.md#client-binaries
再找到合适的tar包如 https://dl.k8s.io/v1.16.0/kubernetes-client-linux-amd64.tar.gz

wget https://dl.k8s.io/v1.16.0/kubernetes-client-linux-amd64.tar.gz
tar -zxvf kubernetes-client-linux-amd64.tar.gz
cd kubernetes/client/bin
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
kubectl version
More ~

Error loading config file &quot;/var/lib/minikube/kubeconfig&quot;: open /var/lib/minikube/kubeconfig: permission denied

inikube start时minikube logs中报

Error loading config file "/var/lib/minikube/kubeconfig": open
/var/lib/minikube/kubeconfig: permission denied

解决方法:

sudo setenforce 0

再次执行minikube start即可

注意 这个setenforce重启会失败,需要修改/etc/selinux/config 将SELINUX=enforcing改为 SELINUX=disabled
然后重启即可。

More ~