1.nginx svc deployment
[root@k8s k8s4nginx]# cat deploynginx.yaml ################################# apiVersion: v1 kind: Service metadata: name: nginx0920 labels: app: nginx0920 spec: ports: - port: 80 targetPort: 80 # clusterIP: None selector: apps: myweb type: NodePort [root@k8s k8s4nginx]# cat myweb.yaml apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx-deployment-file spec: replicas: 1 template: metadata: labels: apps: myweb spec: containers: - name: nginx image: nginx:latest ports: - containerPort: 80
------------------------------------------------------------------------------
1.简单的例子
[root@k8s servicesidecar]# cat service.yaml apiVersion: v1 kind: Service metadata: name: tomcat03 labels: app: tomcat03 spec: ports: - port: 80 targetPort: 8080 nodePort: 30179 type: NodePort selector: apps: tomcat03
2.deployment
[root@k8s servicesidecar]# cat myweb.yaml apiVersion: extensions/v1beta1 kind: Deployment metadata: name: tomcat03 spec: replicas: 1 template: metadata: labels: apps: tomcat03 spec: containers: - name: tomcat01 image: k8s.gcr.io/tomcat:centos714 ports: - containerPort: 8080 volumeMounts: - name: varlog mountPath: /docker_home/local/tomcat8/logs - name: logstash01 image: k8s.gcr.io/eslogstash:7.5.1 volumeMounts: - name: varlog mountPath: /tmp - name: conffile mountPath: /usr/share/logstash/pipeline/ - name: yamlfile mountPath: /usr/share/logstash/config/ volumes: - name: varlog hostPath: path: /tmp/tomcatlog - name: conffile hostPath: path: /usr/share/logstash/pipeline/ - name: yamlfile hostPath: path: /usr/share/logstash/config/