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>

  • 相关阅读:
    用户场景故事
    我喜欢的输入法
    课堂练习-----查找水王
    《你的灯亮着吗》阅读笔记1
    补第二阶段冲刺站立会议6(原6月8日)
    补第二阶段冲刺站立会议5(原6月7日)
    补第二阶段冲刺站立会议4(原6月6日)
    补第二次冲刺站立会议3(原6月5日)
    补第二次冲刺站立会议2(原6月4日)
    补第二次阶段冲刺站立会议1(原6月3日)
  • 原文地址:https://www.cnblogs.com/zc1741845455/p/11151605.html
Copyright © 2011-2022 走看看