分类目录归档:未分类

k8s的几种快捷安装方式

https://gitee.com/q7104475/K8s:更简单的方式

1.https://github.com/easzlab/kubeasz,以Ansible工具进行远程安装。
2.https://github.com/fanux/sealos,离线安装
3.kuboard.cn的教程安装
4.rancher管理工具内自带安装引导。
5.基于kubespray工具安装,因为防火墙的原因,需要修改为国内镜像源。
https://blog.csdn.net/forezp/article/details/82730382
https://blog.csdn.net/zhouzixin053/article/details/104418164
其它参考:
https://github.com/kelseyhightower/kubernetes-the-hard-way
https://github.com/opsnull/follow-me-install-kubernetes-cluster

k8s常用命令

1.获取所有命名空间
kubectl get ns
2.获取所有某个命名空间的所有pods
kubectl get pods –namespace nginx-ingress
3.获取命名空间下的所有服务【它会返回服务的IP和端口】
kubectl get svc -n istio-system 或 kubectl get service -n istio-system

[root@k8smaster ~]# kubectl get svc
NAME          TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
details       ClusterIP   10.96.191.232   <none>        9080/TCP   26h
kubernetes    ClusterIP   10.96.0.1       <none>        443/TCP    12d
productpage   ClusterIP   10.96.167.107   <none>        9080/TCP   26h
ratings       ClusterIP   10.96.29.174    <none>        9080/TCP   26h
reviews       ClusterIP   10.96.0.213     <none>        9080/TCP   26h

4.直接访问某个服务及相应端号。
curl -v 10.96.167.107:9080
5.容器的IP段为10.100.xxx.xxx,而ClusterIP又是存放在哪里呢?它实际上是不存在的但却是被kube-proxy分配和保存在iptables上的。
iptables -S -t nat

[root@k8sworker ~]# iptables -S -t nat|grep 10.96.167.107
-A KUBE-SERVICES ! -s 10.100.0.0/16 -d 10.96.167.107/32 -p tcp -m comment --comment "default/productpage:http cluster IP" -m tcp --dport 9080 -j KUBE-MARK-MASQ
-A KUBE-SERVICES -d 10.96.167.107/32 -p tcp -m comment --comment "default/productpage:http cluster IP" -m tcp --dport 9080 -j KUBE-SVC-ROH4UCJ7RVN2OSM4

普通用户也可重启nginx

1.修改nginx.conf为abc:root启动

  user  abc abc;  #以普通用户启,但实际上是master为root,worker进程是abc。
或 
  user abc root;

2.修改nginx

chown root nginx #nginx必须是root用户拥有者。
chmod a+s nginx  #把x属性改为s属性。
ll nginx
-rwsr-sr-x 1 root root 2030760 Mar  5 11:52 nginx

终端测试验证工具

https://misc.flogisoft.com/bash/home
终端配色:https://misc.flogisoft.com/bash/tip_colors_and_formatting
colors256.sh

#!/bin/bash
for fgbg in 38 48 ; do # Foreground / Background
    for color in {0..255} ; do # Colors
        # Display the color
        printf "\e[${fgbg};5;%sm  %3s  \e[0m" $color $color
        # Display 6 colors per lines
        if [ $((($color + 1) % 6)) == 4 ] ; then
            echo # New line
        fi
    done
    echo # New line
done
exit 0

colors_and_formatting.sh

#!/bin/bash
#Background
for clbg in {40..47} {100..107} 49 ; do
        #Foreground
        for clfg in {30..37} {90..97} 39 ; do
                #Formatting
                for attr in 0 1 2 4 5 7 ; do
                        #Print the result
                        echo -en "\e[${attr};${clbg};${clfg}m ^[${attr};${clbg};${clfg}m \e[0m"
                done
                echo #Newline
        done
done
exit 0

——-
http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
http://www.xfree86.org/current/ctlseqs.html
Linux环境下,主要都是泛VT102的终端,以下是vt102终端。
https://vt100.net/docs/vt102-ug/introduction.html
https://vt100.net/docs/vt102-ug/contents.html
微软的
https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
VT100,VT101,
参考开源:https://konsole.kde.org/

headless vt100 emulator
https://github.com/JulienPalard/vt100-emulator
https://github.com/freanux/VTE

自动拉起服务脚本

crontab -e
*/1 * * * * sh /data/scripts/run-flow.sh start
#!/bin/sh
 
path_current=`pwd`
path_script=$(cd "$(dirname "$0")"; pwd)
mode=$1
 
logfile=/data/scripts/check.log
app_process=`ps -ef | grep "flowservice"| grep -v grep`
echo `date` >> $logfile
echo "ready to check...." >> $logfile
case "$mode" in
   'start')
        echo "$app_process" >> $logfile
        echo "it's ready to start op...."
        if test -n "$app_process"; then
                echo ""
                echo "$app_process"
                echo ""
        else
                cd $path_script   #进入脚本所在目录下,目的是使springboot的config目录生效。
                nohup /data/code/service.flow.wps.cn/flowservice --config=/data/code/service.flow.wps.cn/config/config-prod.toml > /data/code/service.flow.wps.cn/info.txt 2>&1 &
                echo "success to restart flowservice" >> $logfile
                cd $path_current
 
        fi
 
        echo 'success to start.'
        ;;
   'stop')
        echo "it's ready to check process..."
        if test -n "$app_process"; then
                echo "had find app process informaton"
                echo $app_process | awk '{print ($2)}' | xargs kill -9
        fi
        echo 'success to kill.'
        ;;
    *)
        basename=`basename "$0"`
        echo "Usage: $basename  {start|stop}  [ server options ]"
        exit 1
        ;;
esac
exit 1

终端开发文档参考

终端如VT100,VT50,VT220等终端,其相关的文档都汇聚在这个网站上。
https://vt100.net/
http://rtfm.etla.org/xterm/ctlseq.html重点推荐
http://man.he.net/man4/console_codes【Linux Console Codes】【Linux下的console文档,是vt102的子集】
Vt102是vt100家族的第二代指令,在原有vt100基础上增加了行插入行滚动的几个指令。

sed提取json中有用字符串

 
mytest='"summary":{"day":{"burstTotal":0,"dropTotal":135764,"flowTotal":69449},"input":{"spanCount":900,"spanInterval":10},"spanNow":{"burstTotal":0,"dropTotal":1,"flowTotal":4,"now":1548691410},"spans"'
echo $mytest| sed 's/\(.*\)"day":{"burstTotal":\([[:alnum:]]*\),"dropTotal":\([[:alnum:]]*\),"flowTotal":\([[:alnum:]]*\).*/\4/' && echo ":flow121"

解决WIN10显示文字模糊

主要原因是系统允许应的缩放比例生效,按如下修改可解决。
1.桌面右键->显示设置->高级缩放设置如下图:

2.在高级缩放设置中,开启“允许window尝试修复应用,使其不糊模”,及在自定义缩放比例上,填上100%的缩放显示。