分类目录归档:docker

ISTIO的版本依赖

ISTIO的版本支持情况。
公司支持的版本是K8S-1.15.7和ISTIO-1.6
https://istio.io/latest/docs/setup/platform-setup/

Istio 1.6 has been tested with these Kubernetes releases: 1.15,1.16, 1.17, 1.18

docker-compose的陷阱

docker-compose如果不配置network属性,则会创建一个新的子网,而这个子网的网段极有可能与某个内网网段发生冲突。
所以最好在docker-compose.yml中增加network属性配置。
docker-compose启动服务的过程包括以下过程:
第一步创建子网网桥。可以通过”ip route”获取到相关子网IP。
第二步按服务依赖启动服务

{
"bip":"192.168.55.1/24"
}
<pre>
<pre lang="geshi">
networks:
  default:
    driver: bridge
    driver_opts:
      com.docker.network.enable_ipv6: "false"
    ipam:
      driver: default
      config:
        - subnet: 192.168.56.0/24

MQTT

MQTT服务器非常多,如apache的ActiveMQ,emtqqd,HiveMQ,Emitter,Mosquitto,Moquette等等。

使用容器Mosquitto的MQTT实现。

mosquitto_sub -t ‘test/topic’ -c -i id -q 1
mosquitto_pub -t ‘test/topic’ -m ‘hello world23334’ -q 1

mosquitto_sub -t ‘test/topic’ -c -i id -q 1 -u abc -P 123
mosquitto_pub -t ‘test/topic’ -m ‘hello world23334’ -q 1 -u abc -P 123

枚举问题POD及输出其问题

1.获取当前所有的命名空间
kubectl get ns
2.遍历命名空间,检查非Running状态的容器如ImagePullBackOff/ContainerCreating等,如下。
kubectl get pods -n kube-system

 [root@k8smaster ~]# kubectl get pods -n kube-system
NAME                                       READY   STATUS              RESTARTS   AGE
calico-kube-controllers-5b8b769fcd-lsjt4   1/1     Running             2          6d3h
calico-node-6l6r4                          1/1     Running             2          6d2h
calico-node-gt95n                          1/1     Running             2          6d3h
coredns-546565776c-4bn2d                   1/1     Running             2          6d3h
coredns-546565776c-cwpk7                   1/1     Running             2          6d3h
etcd-k8smaster                             1/1     Running             2          6d3h
kube-apiserver-k8smaster                   1/1     Running             3          6d3h
kube-controller-manager-k8smaster          1/1     Running             2          6d3h
kube-proxy-7s8dw                           1/1     Running             2          6d2h
kube-proxy-cbgtv                           1/1     Running             2          6d3h
kube-scheduler-k8smaster                   1/1     Running             2          6d3h
kuboard-7bb89b4cc4-bk7d4                   0/1     ContainerCreating   0          15m
metrics-server-7f96bbcc66-qjk5b            0/1     ContainerCreating   0          15m

3.获取问题POD的输出内容。

kubectl describe pod kuboard-7bb89b4cc4-bk7d4 --namespace=kube-system

查看容器的启动参数

1.pip install runlike
2.runlike -p 容器ID

root@ubuntu:~# runlike -p 498c3ad49c46
docker run \
        --name=nginx \
        --hostname=nginx \
        --env=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
        --env='NGINX_VERSION=1.15.12-1~stretch' \
        --env='NJS_VERSION=1.15.12.0.3.1-1~stretch' \
        --volume=/data/php/dnmp/nginx/conf.d:/etc/nginx/conf.d:ro \
        --volume=/data/php/www:/www:rw \
        --volume=/data/php/dnmp/nginx/nginx.conf:/etc/nginx/nginx.conf:ro \
        --volume=/etc/nginx/conf.d \
        --volume=/etc/nginx/nginx.conf \
        --volume=/www \
        --network=dnmp_lnmp \
        -p 443:443 \
        --expose=80 \
        --label com.docker.compose.project="dnmp" \
        --label com.docker.compose.version="1.18.0" \
        --label com.docker.compose.oneoff="False" \
        --label com.docker.compose.service="nginx" \
        --label com.docker.compose.config-hash="4ad2cd21b7c3c4d0b69776274ea51f5de602a725aa
f3ec1c14c39511051aa904" \
        --label maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>" \
        --label com.docker.compose.container-number="1" \
        --detach=true \
        nginx:latest \
        nginx -g 'daemon off;'

容器清理

1.列举所有容器列表(docker clean)
docker ps -aq
2.停止所有容器
docker stop $(docker ps -aq)
3.删除所有容器
docker rm $(docker ps -aq)
4.清理所有容器
docker system prune -a -f

因为docker版本落后的原故,可能会导致更新版本的docker构造出来的镜像不一定完全兼容旧版本的docker,从而引发挂载目录时内部权限的错误。
移除当前版本:
rpm -qa | grep docker|xargs yum remove -y
安装最新版本:
curl -fsSL https://get.docker.com/ | sh

miniserver配置

version: '3.1'
 
services:
  mysql:
    image: mysql:5.6.40
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: 123456
    # links:
    ports:
      - 3306:3306
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - /opt/mysql/data:/var/lib/mysql
 
  redis:
    image: docker.io/redis:latest
    restart: always
    ports:
      - 6379:6379
 
  redis-cluster:
    image: grokzen/redis-cluster:5.0.7
    restart: always
    environment:
      STANDALONE: 'true'
      IP: '0.0.0.0'
    ports:
      - '7000-7050:7000-7050'
      - '5000-5010:5000-5010'
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
 
  prometheus:
    image: prom/prometheus:v2.15.2
    restart: always
    ports:
      - 9090:9090

node的typescript的常用操作

1.安装node版本,建议选择v8.11.3版本。

https://nodejs.org/dist/v8.11.3/node-v8.11.3-x64.msi<pre>
2.安装visual studio code,选择最新版。
【npm的所有命令,请不要powershell中执行,目前还不知道为什么在本人环境发现在执行npm config set注册下载源时,会出错,且错得很离谱。故需要用cmd.exe来解决。】
3.安装全局组件。
  <pre lang="geshi">
     npm install -g typescript
     npm install -g pm2
     npm install -g ts-node

4.安装本地组件
npm install
5.如果觉得安装有问题,可以直接清理npm缓存及组件。
%appdata%/npm和%appdata%/npm

woweb的yii2容器化服务部署

version: '3.1'
 
networks:
  default:
    driver: bridge
    driver_opts:
      com.docker.network.enable_ipv6: "false"
    ipam:
      driver: default
      config:
        - subnet: 192.168.57.0/24
 
services:
  mysql:
    image: mysql:5.5.60
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: abc3.0123
    # links:
    ports:
      - 13306:3306
      # 13306端口是补人使用的,不能随便修改。
    volumes:
      - ./data/share/localtime:/etc/localtime:ro
      - ./data/share/timezone:/etc/timezone:ro
      - ./data/mysql/data:/var/lib/mysql
 
  php:
    image: yiisoftware/yii2-php:7.2-fpm
    restart: always
    ports:
      - 9900:9000
    links:
      - mysql:mysql
    extra_hosts:
      - mysql.woterm.com:abc.24.129.221
    depends_on:
      - mysql
    volumes:
      - ./data/share/localtime:/etc/localtime:ro
      - ./data/share/timezone:/etc/timezone:ro
      - ./data/wwwroot:/home/wwwroot
      - ./data/wwwlogs:/home/wwwlogs
      - ./../../woweb:/home/wwwroot/woweb
    # php-fpm运行的用户为www-data,需要将wwwroot的权限为[chmod a+w ]
 
  nginx:
    image: nginx:1.13.6
    restart: always
    ports:
      - 80:80
    links:
      - mysql
      - php
    depends_on:
      - mysql
      - php
    volumes:
      - ./data/share/localtime:/etc/localtime:ro
      - ./data/share/timezone:/etc/timezone:ro
      - ./data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./data/nginx/conf/vhost:/etc/nginx/vhost:ro
      - ./data/wwwroot:/home/wwwroot
      - ./data/wwwlogs:/home/wwwlogs
      - ./../../woweb:/home/wwwroot/woweb
 
  ftp:
    image: stilliard/pure-ftpd
    restart: always
    ports:
      - "21:21"
    volumes:
      - ./data/vsftp:/home/vsftp
    environment:
      FTP_USER_NAME: uftp
      FTP_USER_PASS: xxxxxxx
      FTP_USER_HOME: ./data/vsftp/home