Nginx-rc.yaml
apiVersion: v1 kind: ReplicationController Metadata: name: Nginx-controller labels: name: Nginx spec: replicas: 2 selector: name: Nginx template: Metadata: labels: name: Nginx spec: containers: - name: Nginx image: docker.io/blacklabelops/Nginx imagePullPolicy: IfNotPresent ports: - containerPort: 80
Nginx-svc.yaml
apiVersion: v1 kind: ReplicationController Metadata: name: Nginx-controller labels: name: Nginx spec: replicas: 2 selector: name: Nginx template: Metadata: labels: name: Nginx spec: containers: - name: Nginx image: docker.io/blacklabelops/Nginx imagePullPolicy: IfNotPresent ports: - containerPort: 80 [root@k8s k8s_data]# cat Nginx-svc.yaml apiVersion: v1 kind: Service Metadata: name: Nginx labels: name: Nginx-servcie spec: type: NodePort ports: - port: 8000 protocol: TCP targetPort: 80 nodePort: 30088 selector: name: Nginx
MysqL-rc.yaml
apiVersion: v1 kind: ReplicationController Metadata: name: MysqL spec: replicas: 1 selector: app: MysqL template: Metadata: labels: app: MysqL spec: containers: - name: MysqL image: MysqL ports: - containerPort: 3306 env: - name: MysqL_ROOT_PASSWORD value: "123456"
Nginx-svc.yaml
apiVersion: v1 kind: Service #表明是K8s Service Metadata: name: MysqL #Service的全局唯一名称 spec: ports: - port: 3306 #Service提供服务的端口号 selector: #Service对应的Pod拥有这里定义的标签 app: MysqL
myweb
myweb-rc.yaml
apiVersion: v1 kind: ReplicationController Metadata: name: myweb spec: replicas: 1 #Pod副本期待数量为5 selector: app: myweb template: Metadata: labels: app: myweb spec: containers: - name: myweb image: kubeguide/tomcat-app:v1 ports: - containerPort: 8080 env: - name: MysqL_SERVICE_HOST value: "MysqL" - name: MysqL_SERVICE_PORT value: "3306"
myweb-svc.yaml
apiVersion: v1 kind: Service Metadata: name: myweb spec: type: NodePort ports: - port: 8080 nodePort: 31111 selector: app: myweb
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。