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>

  • 相关阅读:
    移除DOM节点
    php 301重定向
    PHP 面向对象:方法重载
    JSON
    轮播图alt作为标题
    php 开发规范
    struts2文件上传 判断大小
    twitter api
    php 方法重写,参数不同,报错: Declaration of should be compatible with that
    Delphi中判断当前程序运行过程中长时间无鼠标与键盘操作
  • 原文地址:https://www.cnblogs.com/zc1741845455/p/11151605.html
Copyright © 2011-2022 走看看