【发布时间】:2018-09-21 11:38:43
【问题描述】:
我设法用 minikube 创建和部署了一个 k8s 集群,运行了一个简单的 hello-world node.js 应用程序的 4 个副本,使用以下配置。
应用程序的 Dockerfile:
FROM ubuntu:latest
RUN apt-get update
RUN apt-get -qq update
RUN apt-get install -y nodejs npm
# TODO could uninstall some build dependencies
# debian installs `node` as `nodejs`
RUN update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10
COPY package.json package.json
RUN npm install
COPY . .
CMD ["node", "app.js"]
k8s 部署 yml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: node-deployment
labels:
app: node-app
spec:
replicas: 4
selector:
matchLabels:
app: node-app
template:
metadata:
labels:
app: node-app
spec:
containers:
- name: node-app
image: my-repo/ubuntu-node:sectry
ports:
- containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
name: node-service
labels:
app: node-app
spec:
type: NodePort
ports:
- port: 3000
protocol: TCP
selector:
app: node-app
我的问题是如何为它添加一个 nginx 容器?我知道 k8s 集群已经进行了负载均衡,但我真的很想使用 NGINX 功能。
【问题讨论】:
-
查看此tutorial 以通过仪表板获取它。仅部署 NGINX 不需要深入了解 Kubernetes 的配置。
标签: nginx kubernetes minikube