我有一个我正在做的码头图像
docker run --name test -h test -p 9043:9043 -p 9443:9443 -d ibmcom/websphere-traditional:install我正在尝试将其放入kubernetes部署文件中,并且我有以下内容:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: websphere
spec:
replicas: 1
template:
metadata:
labels:
app: websphere
spec:
containers:
- name: websphere
image: ibmcom/websphere-traditional:install
ports:
- containerPort: 9443
resources:
requests:
memory: 500Mi
cpu: 0.5
limits:
memory: 500Mi
cpu: 0.5
imagePullPolicy: Always我的service.yaml
apiVersion: v1
kind: Service
metadata:
name: websphere
labels:
app: websphere
spec:
type: NodePort #Exposes the service as a node ports
ports:
- port: 9443
protocol: TCP
targetPort: 9443
selector:
app: websphere我可以获得如何在我的部署文件中映射2个端口的指导吗?
发布于 2018-09-10 00:10:03
您可以根据需要添加任意多个端口。
这是你的deployment.yml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: websphere
spec:
replicas: 1
template:
metadata:
labels:
app: websphere
spec:
containers:
- name: websphere
image: ibmcom/websphere-traditional:install
ports:
- containerPort: 9043
- containerPort: 9443
resources:
requests:
memory: 500Mi
cpu: 0.5
limits:
memory: 500Mi
cpu: 0.5
imagePullPolicy: IfNotPresent这是你的service.yml
apiVersion: v1
kind: Service
metadata:
name: websphere
labels:
app: websphere
spec:
type: NodePort #Exposes the service as a node ports
ports:
- port: 9043
name: hello
protocol: TCP
targetPort: 9043
nodePort: 30043
- port: 9443
name: privet
protocol: TCP
targetPort: 9443
nodePort: 30443
selector:
app: websphere检查您的kubernetes api-server配置,nodePorts的范围是多少(通常是30000-32767,但它是可配置的)。
编辑
如果我从deployment.yml中删除resources部分,它将正确启动(大约5分钟后)。下面是日志的一小段:
9/10/18 8:08:06:004UTC 00000051 webcontainer I com.ibm.ws.webcontainer.VirtualHostImpl addWebApplication SRVE0250I: Web模块默认Web应用程序已绑定到default_host:9080,:80,:9443,:5060,:5061,:443。
连接到它时会出现问题(我使用带有traefik的ingress ),原因是证书(我想):
SSL9/10/18 10:15:08:413 UTC 000000a4 SSLHandshakeE E SSLC0008E:无法初始化
连接。未经授权的访问被拒绝或安全设置已过期。例外是javax.net.ssl.SSLException:无法识别的SSL消息,明文连接?
要解决这个问题(我没有进一步讨论),这可能会有帮助:SSLHandshakeE E SSLC0008E: Unable to initialize SSL connection. Unauthorized access was denied or security settings have expired
正在尝试与port-forward连接

然后使用浏览器进行连接,我会登录到这个页面:

发布于 2019-09-14 03:10:18
在kubernetes中,你可以使用#port label来定义你的端口。此标签位于您的部署中的端口配置下。根据配置,您可以简单地定义任意数量的端口。以下示例说明如何定义两个端口。
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app: MyApp
ports:
- name: http
protocol: TCP
port: 80
targetPort: 9376
- name: https
protocol: TCP
port: 443
targetPort: 9377https://stackoverflow.com/questions/52246270
复制相似问题