qdyxmas's Room

Done is better than perfect...

k8s部署管理docker镜像

docker安装与注册

1.安装python文件
    sudo yum install -y python36
2.安装docker
    sudo yum install -y yum-utils device-mapper-persistent-data lvm2
    sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
    sudo yum install docker-ce
3.启动docker
    systemctl enable docker
    systemctl start docker
4.下载docker python3.6的镜像
    docker search python #查看python相关的镜像文件
    docker pull markadams/chromium-xvfb-py3    #这个是selenium的一个镜像,包含python36
5.下载xk_monitor配置文件,然后build创建新的镜像文件xkmonitor
    docker build -t xkmonitor -f Dockerfile .
    docker run  -d -i -t xkmonitor /bin/bash    #如果能够进入表示已经启动
6.注册docker账号,然后创建命名空间xkool-monitor
    docker images获取xkmonitor的image id
    然后给xkmonitor镜像打完tag
    docker tag image_id soloxmas/xkool-monitor
    docker login #输入注册的用户名和密码 
    docker push soloxmas/xkool-monitor #把打好tag的image推送到docker库中以便拉取,这一步比较慢

以下是k8s的部分

1.下载kubectl
    curl -Lo kubectl    http://kubernetes.oss-cn-hangzhou.aliyuncs.com/kubernetes-release/release/v1.16.0/bin/linux/amd64/kubectl
    chmod +x kubectl
    cp kubectl /usr/local/bin

2.下载minikube后启动
    curl -Lo minikube http://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v1.4.0/minikube-linux-amd64
    chmod +x minikube
    cp minikube /usr/local/bin
    minikube start --vm-driver=none
    minikube status #查看状态
3.创建k8s命名空间
    kubectl create namespace xkool-monitor
4.通过配置文件来运行容器
    kubectl apply -f monitor-deploy-port.yml

5.把pod中的端口映射出来
    echo 1 > /proc/sys/net/ipv4/ip_forward  #开启linux转发功能

其他k8s常用命令

k8s中正确删除一个pod

先删除pod,再删除deployment
    kubectl get pod -n xkool-monitor        #查看有哪些pod在运行
        [root@localhost xk_monitor]# kubectl get pod -n xkool-monitor
        NAME                             READY   STATUS    RESTARTS   AGE
        monitor-5746bfdb9b-hnrsq         1/1     Running   0          4m8s
        xkool-monitor-6cd4d56f55-9hvjx   1/1     Running   2          6h53m
    kubectl get deployment -n xkool-monitor #查看有哪些pod在运行
        [root@localhost xk_monitor]# kubectl get deployment -n xkool-monitor
        NAME            READY   UP-TO-DATE   AVAILABLE   AGE
        monitor         1/1     1            1           9m58s
        xkool-monitor   1/1     1            1           6h59m
kubectl delete pod xkool-monitor-6cd4d56f55-9hvjx -n xkool-monitor  #删除pod
kubectl delete deployment xkool-monitor -n xkool-monitor            #删除deployment

ubuntu 18.04 k8s/docker

1.修改阿里源
2.安装docker 
    sudo apt-get update
     apt-get install docker.io=17.12.1-0ubuntu1
3.启动docker
    systemctl start docker
    systemctl enable docker #设置开机启动
4.拉取docker image镜像
    docker pull soloxmas/xkool-monitor
5.下载kubectl
    wget "https://storage.googleapis.com/kubernetes-release/release/v1.12.2/bin/linux/amd64/kubectl" -O "/usr/local/bin/kubectl"
    cp kubectl /usr/local/bin/
    chmod +x /usr/local/bin/kubectl
6.下载minikube和启动
    1. curl -Lo minikube http://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v0.30.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
    2. minikube start --vm-driver=none --registry-mirror=https://registry.docker-cn.com
7.创建一个空间
    kubectl create namespace xkool-monitor
    kubectl apply -f monitor-deploy.yml
8.查看结果
    root@xkool:~/xk_monitor# kubectl get pod -n xkool-monitor
    NAME                      READY   STATUS    RESTARTS   AGE
    monitor-f99d4df76-2pvfh   1/1     Running   0          14m

标签   

16 评论

  1. KcnIZ
    /回复

    Pills information for patients. Brand names. <a href="https://lyricafor.top">buying lyrica without insurance</a> in Canada All news about medicine. Read here.

  2. JaniceWeS
    /回复

    how to buy cialis <a href="https://mycialistabs.com/">is there a generic for cialis</a> cialis picture

  3. TiffanyreD
    /回复

    order cialis online <a href="https://toptadalafiltabs.com/">tadalafil online</a> 20 mg cialis

  4. Stellavam
    /回复

    good topics to write an argumentative essay on <a href="https://topessaywriterfas.com/">cheap essay writing service uk</a> how to write an essay on a short story

  5. RebeccaMew
    /回复

    write me a essay <a href="http://writemyessayslfd.com/">the write stuff thinking through essays</a> write that essay

  6. FrancesHix
    /回复

    buy generic 100mg viagra online <a href="https://mrviagrashop.com">viagra for men</a> cvs viagra

  7. Martinanulse
    /回复

    itsoktocry viagra <a href="https://mysildenafilkr.com/">cheap viagra</a> viagra jokes

  8. Kathryngogue
    /回复

    what is the difference between viagra and cialis <a href="http://tadalafilled.com/">tadalafil dosage</a> is cialis over the counter

  9. JjmVO
    /回复

    references on a resume <a href="http://coverletterforresumetop.com/">help me create a resume</a> special education teacher resume

  10. KreLS
    /回复

    resume accent <a href="https://writingacoverletteronline.com/">build your resume</a> project manager cover letter

  11. ZytML
    /回复

    cost of viagra <a href="https://edviagramaster.net/">viagra triangle</a> viagra without a doctor prescription canada

  12. GyxMS
    /回复

    compra viagra <a href="https://sildenafilviagratop.com">walgreens generic viagra</a> sildenafil

  13. TelRU
    /回复

    cialis dosage 40 mg <a href="https://cialisortadalafil.com/">tadalafil side effects long term</a> buy cialis online reddit

  14. UstNJ
    /回复

    cialis <a href="https://topcialistabs.com/">https://topcialistabs.com/</a> viagra vs cialis forum

  15. KvyER
    /回复

    <a href="https://5bz.ru/">информационная база предприятий россии</a>

  16. yztfmdh
    /回复

    qdyxmas's Room yztfmdh http://www.g4cryf67ka15vh4pb2p2h51h836xx608s.org/ <a href="http://www.g4cryf67ka15vh4pb2p2h51h836xx608s.org/">ayztfmdh</a> [url=http://www.g4cryf67ka15vh4pb2p2h51h836xx608s.org/]uyztfmdh[/url]

评论