暴漏container端口

To expose the dev-app container as a service on port 30081 on the controlplane node, you can create a Kubernetes service of type NodePort. Here are the steps to do it:

1. Write a YAML file for the service definition. For example, create a file named dev-app-service.yaml with the following content:

```
apiVersion: v1
kind: Service
metadata:
  name: dev-app-service
spec:
  type: NodePort
  selector:
    app: dev-app
  ports:
    - name: http
      port: 80
      targetPort: 80
      nodePort: 30081
```

2. Apply the YAML file to create the service:

```
kubectl apply -f dev-app-service.yaml
```

This will create a service named dev-app-service of type NodePort. The service will select the pods with the label app=dev-app. It will expose port 80 on the pod as port 30081 on all the nodes in the cluster.

3. Verify that the service is created:

```
kubectl get svc dev-app-service
```

This will output the details of the service, including the external IP address that you can use to access the application on port 30081:

```
NAME             TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
dev-app-service  NodePort   10.101.86.228   <none>        80:30081/TCP   1m
```

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值