zoukankan      html  css  js  c++  java
  • k8s cookbook读书笔记 第二章

    走一遍概念  

    • An overview of Kubernetes control
    • f Working with pods
    • f Working with a replication controller
    • f Working with services
    • f Working with volumes
    • f Working with secrets
    • f Working with names
    • f Working with namespaces
    • f Working with labels and selectors
    1. An overview of Kubernetes control

    查看k8s版本

      % kubectl version

    是如何做到的

      kubectl通过restful api 连接kubernetes api server

    如何工作的

      kubectl [command] [TYPE] [NAME] [flags]

          /usr/local/bin/kubectl run my-first-nginx --image=nginx

          However, you can write either a YAML file or a JSON file to perform similar operations. 

    # cat nginx.yaml
    apiVersion: v1
    kind: ReplicationController
    metadata:
    name: my-first-nginx
    spec:
    replicas: 1
    template:
    metadata:
    labels:
    app: nginx
    spec:
    containers:
    - name: my-first-nginx
    image: nginx

    Then specify the  create -f option to execute the  kubectl command as follows

    # kubectl create -f nginx.yaml
    replicationcontroller "my-first-nginx" created

     status of the replication controller

    # kubectl get replicationcontrollers
    CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS AGE
    my-first-nginx my-first-nginx nginx app=nginx 1 12s

     缩写

    kubectl get rc
    CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS AGE
    my-first-nginx my-first-nginx nginx app=nginx 1 1m

    删除

    # kubectl delete rc my-first-nginx
    replicationcontroller "my-first-nginx" deleted

    2.pods

       是k8s中最小的可部署单元

       每个pod被进程id,网络,进程间通信,时间命名空间隔离。

       docker pull centos
    # cat my-first-pod.yaml
    apiVersion: v1
    kind: Pod
    metadata:
    name: my-first-pod
    spec:
    containers:
    - name: my-nginx
    image: nginx
    - name: my-centos
    image: centos
    command: ["/bin/sh", "-c", "while : ;do curl http://
    localhost:80/; sleep 3; done"]

       

  • 相关阅读:
    各版本mysql乱码的问题解决
    Centos+apache2.4.2+mysql5.5+php5.3.10+memcache+sphinx配置全程
    Mysql 优化
    Mysql 表优化
    Mysql 索引优化
    python整合连续数字的练习,包含itertoolsgroupby用法
    MySQL INTO OUTFILE/INFILE导出导入数据
    python lambda使用if
    mysql小知识
    Python利用urllib2抓取网页返回乱码的问题
  • 原文地址:https://www.cnblogs.com/guxiaobei/p/8065085.html
Copyright © 2011-2022 走看看