如何在私有云kubernetes集群中为Nginx-ingress控制器设置外部IP

时间:2019-05-07 11:57:03

标签: nginx controller kubernetes-ingress

我正在设置一个kubernetes集群来运行Hyperledger Fabric应用程序。我的群集位于私有云上,因此没有负载平衡器。如何为nginx-ingress-controller(待定)设置IP地址以公开我的服务?我认为这会干扰我的Pod的创建,因为当我运行kubectl get pod时,我看到了很多被驱逐的Pod。我使用的证书管理器也需要IP。

CA_POD=$(kubectl get pods -n cas -l "app=hlf-ca,release=ca" -o jsonpath="{.items[0].metadata.name}")

这不会创建任何广告连播。

nginx-ingress-controller-5bb5cd56fb-lckmm      1/1     Running

nginx-ingress-default-backend-dc47d79c-8kqbp   1/1     Running 

其余为

nginx-ingress-controller-5bb5cd56fb-d48sj      0/1     Evicted 

ca-hlf-ca-5c5854bd66-nkcst  0/1    Pending  0         0s
ca-postgresql-0             0/1    Pending  0         0s

我想创建一个Pod,从中可以运行exec命令,例如

kubectl exec -n cas $CA_POD -- cat /var/hyperledger/fabric-ca/msp/signcertscert.pem

1 个答案:

答案 0 :(得分:0)

您不是要公开nginx控制器的IP地址,而是要通过节点端口公开nginx的服务。例如:

// Inflate the custom layout:
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.custom_toast, (ViewGroup)findViewById(R.id.custom_toast_container));

// Fill the custom layout with your own data
TextView text = (TextView) layout.findViewById(R.id.text);
text.setText("This is a custom toast");

// Create the toast and set the custom layout to it
Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();

在这种情况下,您可以像

一样获得服务
piVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: nginx-controller
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  type: NodePort
  ports:
    - port: 80
      nodePort: 30080
      name: http
  selector:
    app: nginx

对于这个问题,为什么您的吊舱处于待处理状态,请描述吊舱行为异常:

curl -v <NODE_EXTERNAL_IP>:30080

最好的方法是使用头盔

kubectl describe pod nginx-ingress-controller-5bb5cd56fb-d48sj