<dfn id="hx5t3"><strike id="hx5t3"><em id="hx5t3"></em></strike></dfn>

    <thead id="hx5t3"></thead><nobr id="hx5t3"><font id="hx5t3"><rp id="hx5t3"></rp></font></nobr>

    <listing id="hx5t3"></listing>

    <var id="hx5t3"></var>
    <big id="hx5t3"></big>

      
      

      <output id="hx5t3"><ruby id="hx5t3"></ruby></output>
      <menuitem id="hx5t3"><dfn id="hx5t3"></dfn></menuitem>

      <big id="hx5t3"></big>

        思過崖

        思過崖 查看完整檔案

        廣州編輯廣州大學  |  心理學 編輯  |  填寫所在公司/組織 www.siguoya.name 編輯
        編輯

        從轉行到入門,記錄我的自學成長之路

        vx:dzc1NzAwNjE=

        個人動態

        思過崖 發布了文章 · 3月16日

        9.6 使用Tectonic在本地搭建多節點K8S集群

        使用Tectonic搭建K8S集群

        # 這種使用方式已被廢棄,涉及到的資源已經在官網無法下載
        # 通過老師提供的安裝包 https://gitlab-demo.com/xiaoquwl/docker-k8s-devops/tree/master/chapter9/tectonic-sandbox-1.7.5-tectonic.1 來安裝遇到了各種坑。。。。。
        https://coreos.com/tectonic/docs/latest/tutorials/sandbox/install.html

        有需要的可以使用Kubeadm:https://www.imooc.com/article...

        獲取集群列表

        kubectl config get-clusters
        NAME
        minikube

        如果我們想通過kubectl管理多個集群,可以將多個集群的config文件合并到~/.kube/config文件中

        關于config合并的規則:https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/

        contexts 操作

        獲取當前的contexts

        kubectl config get-contexts
        CURRENT NAME CLUSTER AUTHINFO NAMESPACE
        * minikube minikube minikube
        ? vagrant ? ?vagrant ? ?kubelet

        切換contexts

        kubectl config use-context vagrant

        查看contexts

        kubectl config get-contexts
        CURRENT NAME CLUSTER AUTHINFO NAMESPACE
        ? minikube minikube minikube
        * vagrant vagrant kubelet
        查看原文

        贊 0 收藏 0 評論 0

        思過崖 發布了文章 · 3月16日

        9.5 Deployment

        Deployment

        新建一個pod_nginx.yml

        apiVersion: apps/v1
        kind: Deployment
        metadata:
          name: nginx-deployment
          labels:
            app: nginx
        spec:
          replicas: 3
          selector:
            matchLabels:
              app: nginx
          template:
            metadata:
              labels:
                app: nginx
            spec:
              containers:
              - name: nginx
                image: nginx:1.12.2
                ports:
                  - containerPort: 80

        然后執行如下命令,即可完成創建

        kubectl create -f pod_nginx.yml

        查看

        kubectl get deployment -o wide
        NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
        nginx-deployment 3 3 3 0 3m nginx nginx:1.12.2 app=nginx
        
        kubectl get rs
        NAME DESIRED CURRENT READY AGE
        nginx-deployment-7498dc98f8 3 3 0 2m
        
        kubectl get pods
        NAME READY STATUS RESTARTS AGE
        nginx-deployment-7498dc98f8-5687w 0/1 ContainerCreating 0 2m
        nginx-deployment-7498dc98f8-f2lbx 0/1 ContainerCreating 0 2m
        nginx-deployment-7498dc98f8-f8zwj 0/1 ContainerCreating 0 2m

        升級image

        kubectl set image deployment nginx-deployment nginx=nginx:1.13
        deployment.apps "nginx-deployment" image updated
        
        NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
        nginx-deployment 3 4 1 0 5m nginx nginx:1.13 app=nginx

        回滾image

        kubectl rollout undo deployment nginx-deployment
        deployment.apps "nginx-deployment"
        
        kubectl get deployment -o wide
        NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
        nginx-deployment 3 4 3 0 7m nginx nginx:1.12.2 app=nginx

        Node

        查看

        kubectl get node -o wide
        NAME STATUS ROLES AGE VERSION EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
        minikube Ready <none> 2d v1.10.0 <none> Buildroot 2018.05 4.16.14 docker://17.12.1-ce

        端口暴露

        # 查看
        kubectl get svc
        NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
        kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 2d
        
        # 端口暴露
        kubectl expose deployment nginx-deployment --type=NodePort
        Error from server (AlreadyExists): services "nginx-deployment" already exists
        
        # 刪除舊的
        kubectl delete services nginx-deployment
        service "nginx-deployment" deleted
        
        # 重新暴露
        kubectl expose deployment nginx-deployment --type=NodePort
        service "nginx-deployment" exposed
        
        # 再次查看,此時可以在宿主機上使用curl 192.168.99.100:30437訪問到web頁面
        kubectl get svc
        NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
        kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 2d
        nginx-deployment NodePort 10.99.122.148 <none> 80:30437/TCP 15s
        查看原文

        贊 0 收藏 0 評論 0

        思過崖 發布了文章 · 3月16日

        9.4 ReplicaSet和ReplicationController

        ReplicationController

        新建一個pod_nginx.yml

        apiVersion: v1
        kind: ReplicationController
        metadata:
          name: nginx
        
        spec:
          replicas: 3
          selector:
            app: nginx
          template:
            metadata:
              name: nginx
              labels:
                app: nginx
            spec:
              containers:
              - name: nginx
                image: nginx
                ports:
                  - containerPort: 80

        然后運行如下

        kubectl create -f pod_nginx.yml
        kubectl get rc
        NAMEDESIREDCURRENTREADYAGE
        nginx3334m
        kubectl get pods
        NAMEREADYSTATUSRESTARTSAGE
        nginx-89s9p1/1Running06m
        nginx-8bjnb1/1Running06m
        nginx-h49m51/1Running06m
        kubectl delete pods nginx-89s9p
        kubectl get pods
        NAME READY STATUS RESTARTS AGE
        nginx-2mvs9 0/1 ContainerCreating 0 <invalid>
        nginx-89s9p 0/1 Terminating 0 9m
        nginx-8bjnb 1/1 Running 0 9m
        nginx-h49m5 1/1 Running 0 9m

        當我們刪掉一個pod的時候,kube會自動幫我們創建另一個pod,從而達到動態的平衡

        # 動態修改pod數量
        kubectl scale rc nginx --replicas=2

        ReplicaSet

        新建一個pod_nginx.yml

        apiVersion: apps/v1
        kind: ReplicaSet
        metadata:
          name: nginx
          labels:
            tier: frontend
        spec:
          replicas: 3
          selector:
            matchLabels:
              tier: frontend
          template:
            metadata:
              name: nginx
              labels:
                tier: frontend
            spec:
              containers:
              - name: nginx
                image: nginx
                ports:
                  - containerPort: 80

        執行

        # 創建
        kubectl create -f pod_nginx.yml
        
        # 查看
        kubectl get rs
        NAME DESIRED CURRENT READY AGE
        nginx 3 3 3 2m
        
        # 擴容
        kubectl scale rs nginx --replicas=1
        查看原文

        贊 0 收藏 0 評論 0

        思過崖 發布了文章 · 3月16日

        9.3 K8S最小調度單位Pod

        與container的關系

        一個Pod可以包含一個或多個container

        Pod管理

        新建一個pod_nginx.yml文件

        apiVersion: v1
        kind: Pod
        metadata:
          name: nginx
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx
            ports:
            - containerPort: 80

        創建

        # 如果安裝失敗或者掛起,可通過kubectl describe pods查看錯誤信息。 
        kubectl create -f pod_nginx.yml
        kubectl get pods
        NAMEREADYSTATUSRESTARTSAGE
        nginx1/1Running02h

        當時安裝過程中遇到的錯誤信息如下:

        Warning FailedCreatePodSandBox 11s kubelet, minikube Failed create pod sandbox: rpc error: code = Unknown desc = failed pulling image "k8s.gcr.io/pause-amd64:3.1": Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

        嘗試著直接在宿主機的iterm2上執行如下語句

        docker pull k8s.gcr.io/pause-amd64:3.1

        確實失敗了,因此懷疑k8s.gcr.io被墻了。

        在Docker for Mac的Preferences - Proxies - Manual proxy configuration中設置如下,然后Apply & Restart即可發現宿主機可以成功pull image了

        http:127.0.0.1:1087
        https:127.0.0.1:1087
        Bypass:localhost,127.0.0.1,docker-registry.somecorporation.com

        但上述的錯誤信息實際上不是在宿主機上pull image導致的,而是在minikube這個虛擬機上pull image導致的。

        因此需要將ssr的listen address從 127.0.0.1:1087 改成 0.0.0.0:1087

        然后minikube ssh,按照docker的proxy文檔 https://docs.docker.com/confi... 在minikube虛擬機上進行如下操作

        sudo mkdir -p /etc/systemd/system/docker.service.d
        touch /etc/systemd/system/docker.service.d/http-proxy.conf
        sudo vi /etc/systemd/system/docker.service.d/http-proxy.conf

        文件內容如下

        [Service]
        Environment="HTTP_PROXY=http://192.168.88.66:1087" "HTTPS_PROXY=http://192.168.88.66:1087" "NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com"

        然后

        sudo systemctl daemon-reload
        sudo systemctl restart docker

        驗證是否生效

        systemctl show --property=Environment docker
        Environment=DOCKER_RAMDISK=yes HTTP_PROXY=http://192.168.88.66:1087 HTTPS_PROXY=http://192.168.88.66:1087 NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com

        退出minikube虛擬機,然后重新執行如下即可

        kubectl delete -f pod_nginx.yml
        kubectl create -f pod_nginx.yml
        minikube stop之后,上述的proxy配置信息就丟失了,需要重新配置,想哭。。。

        刪除

        kubectl delete -f pod_nginx.yml

        查看pods列表

        kubectl get pods -o wide
        NAMEREADYSTATUSRESTARTSAGEIPNODE
        nginx1/1Running06h172.17.0.2minikube

        進入Pod

        kubectl exec -it nginx sh

        查看Pod詳情

        kubectl describe pod nginx

        Pod端口映射

        kubectl port-forward nginx 8080:80

        這種端口映射方式在該行shell程序ctrl+c后就停止了,不建議采用

        查看原文

        贊 0 收藏 0 評論 0

        思過崖 發布了文章 · 3月16日

        9.2 Minikube快速搭建K8S單節點環境

        https://github.com/kubernetes/minikube

        Minikube也是需要虛擬化工具來支持的,例如VirtualBox

        Mac系統上安裝

        依賴kubectl

        heartide@mac> kubectl version
        Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.5", GitCommit:"32ac1c9073b132b8ba18aa830f46b77dcceb0723", GitTreeState:"clean", BuildDate:"2018-06-22T05:40:13Z", GoVersion:"go1.9.7", Compiler:"gc", Platform:"darwin/amd64"}
        
        Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.0", GitCommit:"fc32d2f3698e36b93322a3465f63a14e9f0eaead", GitTreeState:"clean", BuildDate:"2018-04-10T12:46:31Z", GoVersion:"go1.9.4", Compiler:"gc", Platform:"linux/amd64"}

        安裝minikube

        # 下載
        brew cask install minikube
        
        # 查看版本
        heartide@mac> minikube version
        minikube version: v0.28.0

        裝完0.28.0之后,執行后續的minikube start總是失敗,詳見:https://coding.imooc.com/lear...

        因此

        minikube stop
        minikube delete
        brew cask uninstall --force minikube
        brew cask edit minikube
        #See below for file 使用下面的配置覆蓋該文件
        brew cask install minikube

        配置

        cask 'minikube' do
        ? version '0.25.2'
        ? sha256 'dc5b00c4a06e8160bd607732c9a2294598d803716e353293b4463cc2c9539eec'
        ? # storage.googleapis.com/minikube was verified as official when first introduced to the cask
        ? url "https://storage.googleapis.com/minikube/releases/v#{version}/minikube-darwin-amd64"
        ? appcast 'https://github.com/kubernetes/minikube/releases.atom',
        ? ? ? ? ? checkpoint: 'dc5b00c4a06e8160bd607732c9a2294598d803716e353293b4463cc2c9539eec'
        ? name 'Minikube'
        ? homepage 'https://github.com/kubernetes/minikube'
        ? depends_on formula: 'kubernetes-cli'
        ? container type: :naked
        ? binary 'minikube-darwin-amd64', target: 'minikube'
        ? zap trash: '~/.minikube'
        end

        重新安裝

        # 下載安裝
        brew cask install minikube
        
        # 查看版本
        heartide@mac> minikube version
        minikube version: v0.25.2

        啟動minikube

        minikube start

        查看minikube配置

        # kubectl config view
        apiVersion: v1
        clusters:
        - cluster:
        ? ? certificate-authority: /Users/heartide/.minikube/ca.crt
        ? ? server: https://192.168.99.101:8443
        ? name: minikube
        contexts:
        - context:
        ? ? cluster: minikube
        ? ? user: minikube
        ? name: minikube
        current-context: minikube
        kind: Config
        preferences: {}
        users:
        - name: minikube
        ? user:
        ? ? client-certificate: /Users/heartide/.minikube/client.crt
        ? ? client-key: /Users/heartide/.minikube/client.key

        查看minikube狀態

        heartide@mac> kubectl cluster-info
        Kubernetes master is running at https://192.168.99.101:8443
        To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

        進入minikube虛機

        minikube ssh
        查看原文

        贊 0 收藏 0 評論 0

        思過崖 發布了文章 · 3月16日

        9.1 Kubenetes簡介

        swarm與k8s的歷史:https://www.imooc.com/article/23476

        swarm架構

        image.png

        k8s架構

        image.png

        查看原文

        贊 0 收藏 0 評論 0

        思過崖 發布了文章 · 3月16日

        8.7 阿里云的容器服務

        贊 0 收藏 0 評論 0

        思過崖 發布了文章 · 3月16日

        8.6 Docker企業版本地安裝之DTR

        訪問?https://192.168.205.13/manage/settings/dtr?即可看到 Docker Trusted Registry 選項

        • 選擇將DTR安裝在worker節點而不是manager節點上
        • 設置DTR EXTERNAL URL為worker節點對應的ip:https://192.168.205.14
        • Disable TLS verification for UCP

        運行自動生成的shell語句

        [vagrant@docker-ee-work ~]$ docker run -it --rm docker/dtr install --dtr-external-url https://192.168.205.14 --ucp-node docker-ee-work --ucp-username admin --ucp-url https://192.168.205.13 --ucp-insecure-tls

        然后我們通過如下鏈接就可以訪問DTR了

        https://192.168.205.14/
        查看原文

        贊 0 收藏 0 評論 0

        思過崖 發布了文章 · 3月16日

        8.5 Docker企業版本地安裝之UCP

        初始化虛擬機

        Vagrantfile內容如下

        # -*- mode: ruby -*-
        # vi: set ft=ruby :
        Vagrant.require_version ">= 1.6.0"
        boxes = [
        ? ? {
        ? ? ? ? :name => "docker-ee-manager",
        ? ? ? ? :eth1 => "192.168.205.13",
        ? ? ? ? :mem => "5120",
        ? ? ? ? :cpu => "1"
        ? ? },
        ? ? {
        ? ? ? ? :name => "docker-ee-work",
        ? ? ? ? :eth1 => "192.168.205.14",
        ? ? ? ? :mem => "3072",
        ? ? ? ? :cpu => "1"
        ? ? }
        ]
        
        Vagrant.configure(2) do |config|
        ? config.vm.box = "centos/7"
        ? boxes.each do |opts|
        ? ? config.vm.define opts[:name] do |config|
        ? ? ? config.vm.hostname = opts[:name]
        ? ? ? config.vm.provider "virtualbox" do |v|
        ? ? ? ? v.customize ["modifyvm", :id, "--memory", opts[:mem]]
        ? ? ? ? v.customize ["modifyvm", :id, "--cpus", opts[:cpu]]
        ? ? ? end
        ? ? ? config.vm.network :private_network, ip: opts[:eth1]
        ? ? end
        ? end
        ? config.vm.synced_folder ".", "/vagrant", :disabled => true
        ? config.vm.provision "shell", privileged: true, path: "./setup.sh"
        end

        setup.sh

        #!/usr/bin/env bash
        #/bin/sh
        # install some tools
        sudo yum install -y git vim gcc glibc-static telnet bridge-utils
        # start docker service
        sudo groupadd docker
        sudo usermod -aG docker vagrant

        安裝docker-ee

        安裝指南 ?https://docs.docker.com/insta...

        訪問 https://store.docker.com/search?offering=enterprise&type=edition?后,選擇centos版,然后申請試用,即可拿到DOCKERURL地址

        在docker-ee-manager和docker-ee-work上執行如下命令

        export DOCKERURL="[https://storebits.docker.com/ee/centos/sub-3cdef8e1-28a5-45b6-a95c-c9c4c5d0810c](https://storebits.docker.com/ee/centos/sub-3cdef8e1-28a5-45b6-a95c-c9c4c5d0810c)"
        sudo -E sh -c 'echo "$DOCKERURL/centos" > /etc/yum/vars/dockerurl'
        sudo yum install -y yum-utils device-mapper-persistent-data lvm2
        sudo -E yum-config-manager --add-repo "$DOCKERURL/centos/docker-ee.repo"
        sudo yum -y install docker-ee
        sudo systemctl start docker

        查看版本

        [vagrant@docker-ee-manager ~]$ docker version
        Client: Docker Enterprise Edition (EE) 2.0
        ?Version: 17.06.2-ee-14
        ?API version: 1.30
        ?Go version: go1.8.7
        ?Git commit: 6345dd7
        ?Built: Thu Jun 21 18:13:03 2018
        ?OS/Arch: linux/amd64
        Server: Docker Enterprise Edition (EE) 2.0
        ?Engine:
        ? Version: 17.06.2-ee-14
        ? API version: 1.30 (minimum version 1.12)
        ? Go version: go1.8.7
        ? Git commit: 6345dd7
        ? Built: Thu Jun 21 18:14:24 2018
        ? OS/Arch: linux/amd64
        ? Experimental: false

        安裝UCP

        Docker Universal Control Plane

        # 安裝過程中會要求設置UCP的賬號與密碼
        # 由于當前的vagrant虛機ip為192.168.205.13,ucp的--pod-cidr默認是192.168.0.0/16,這會導致網絡沖突
        # 因此需要特別指定--pod-cidr 192.168.0.0/24選項
        [vagrant@docker-ee-manager ~]$ docker container run --rm -it --name ucp -v /var/run/docker.sock:/var/run/docker.sock docker/ucp:3.0.2 install --host-address 192.168.205.13 --interactive --pod-cidr 192.168.0.0/24

        然后通過訪問如下url就可以進入到登陸界面了

        # 證書會不受信任,選擇仍然訪問即可
        https://192.168.205.13/

        登錄成功之后,如果提示Your system is unlicensed,則點擊Upload License,上傳申請試用獲得的License即可。

        重置UCP管理員密碼

        docker exec -it ucp-auth-api enzi "$(docker inspect --format '{{ index .Args 0 }}' ucp-auth-api)" passwd -i

        添加Worker Node

        [vagrant@docker-ee-work ~]$ docker swarm join --token SWMTKN-1-48hxmlsky9gpomdrrs8v6cpyhjc6f3vya9xs143mz24jgoemx6-0oqcwi8hhv8gdxk03ejd19v61 192.168.205.13:2377
        This node joined a swarm as a worker.
        查看原文

        贊 0 收藏 0 評論 0

        思過崖 發布了文章 · 3月16日

        8.4 Docker Cloud之持續集成和持續部署

        如果在docker cloud上綁定了AWS或者Azure之后,會有一個Launch Service選項

        點擊之后,在頁面上勾選AUTODEPLOY,就可以在image有更新之后,就自動部署了

        查看原文

        贊 0 收藏 0 評論 0

        認證與成就

        • 獲得 22 次點贊
        • 獲得 3 枚徽章 獲得 0 枚金徽章, 獲得 0 枚銀徽章, 獲得 3 枚銅徽章

        擅長技能
        編輯

        開源項目 & 著作
        編輯

        (??? )
        暫時沒有

        注冊于 2018-03-30
        個人主頁被 1.4k 人瀏覽

        一本到在线是免费观看_亚洲2020天天堂在线观看_国产欧美亚洲精品第一页_最好看的2018中文字幕