zoukankan      html  css  js  c++  java
  • 使用yaml配置文件管理资源

    [root@k8s-master ~]# vim nginx-deployment.yaml

    apiVersion: apps/v1beta2

    kind: Deployment

    metadata:

      name: nginx-deployment

    spec:

      replicas: 3

      selector:

        matchLabels:

         app: nginx

      template:

        metadata:

         labels:

          app: nginx

        spec:

          containers:

          - name: nginx

            image: nginx:1.10

            ports:

            - containerPort: 80

    [root@k8s-master ~]# kubectl create -f nginx-deployment.yaml

    [root@k8s-master ~]# kubectl get pod

    NAME                                READY     STATUS    RESTARTS   AGE

    busybox-5d4f595646-dzjv4            1/1       Running   0          2d

    nginx-deployment-58d6d6ccb8-6br4c   1/1       Running   0          1m

    nginx-deployment-58d6d6ccb8-6v7m9   1/1       Running   0          1m

    nginx-deployment-58d6d6ccb8-8cp7s   1/1       Running   0          1m

    [root@k8s-master ~]# vim nginx-service.yaml

    apiVersion: v1

    kind: Service

    metadata:

      name: nginx-service

      labels:

        app: nginx

    spec:

      ports:

      - port: 88

        targetPort: 80

      selector:

        app: nginx

    [root@k8s-master ~]# kubectl create -f nginx-service.yaml

    [root@k8s-master ~]# kubectl get svc

    NAME            TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)   AGE

    kubernetes      ClusterIP   10.10.10.1    <none>        443/TCP   4d

    nginx-service   ClusterIP   10.10.10.85   <none>        88/TCP    40s

    [root@k8s-node1 ~]# curl 10.10.10.85:88

    <!DOCTYPE html>

    <html>

    <head>

    <title>Welcome to nginx!</title>

    [root@k8s-node2 ~]# curl 10.10.10.85:88

    <!DOCTYPE html>

    <html>

    <head>

    <title>Welcome to nginx!</title>

  • 相关阅读:
    一个使用 Python 的人工智能聊天机器人框架
    【TensorFlow 官网 可以直接访问】让中国开发者更容易地使用TensorFlow打造人工智能应用
    Object Relational Tutorial 对象关系教程
    Automap sqlalchemy.ext.automap 自动映射数据库表结构
    回溯法
    子集树和排列树
    平衡树
    二叉查找树
    graphviz使用
    linux进程内存布局
  • 原文地址:https://www.cnblogs.com/zc1741845455/p/11151605.html
Copyright © 2011-2022 走看看