nginx入口控制器未在自定义Kubernetes集群中创建负载均衡器IP地址

时间:2018-05-22 11:53:01

标签: nginx kubernetes kubernetes-helm kubernetes-ingress

我有一个通过kubeadm创建的自定义Kubernetes集群。我的服务通过节点端口公开。现在我想使用ingress作为我的服务。

我已经部署了一个通过NodePort公开的应用程序。

以下是我的deployment.yaml:

apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: {{ template "demochart.fullname" . }}
  labels:
    app: {{ template "demochart.name" . }}
    chart: {{ template "demochart.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app: {{ template "demochart.name" . }}
      release: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app: {{ template "demochart.name" . }}
        release: {{ .Release.Name }}
    spec:
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          ports:
            - name: http
              containerPort: 80
          volumeMounts:
            - name: cred-storage
              mountPath: /root/
          resources:
{{ toYaml .Values.resources | indent 12 }}
    {{- with .Values.nodeSelector }}
      nodeSelector:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.affinity }}
      affinity:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.tolerations }}
      tolerations:
{{ toYaml . | indent 8 }}
    {{- end }}
      volumes:
        - name: cred-storage
          hostPath:
            path: /home/aodev/
            type:

以下是values.yaml

replicaCount: 3

image:
  repository: REPO_NAME
  tag: latest
  pullPolicy: IfNotPresent

service:
  type: NodePort
  port: 8007

resources:
  # We usually recommend not to specify default resources and to leave this as a conscious
  # choice for the user. This also increases chances charts run on environments with little
  # resources, such as Minikube. If you do want to specify resources, uncomment the following
  # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
  limits:
    cpu: 1000m
    memory: 2000Mi
  requests:
    cpu: 1000m
    memory: 2000Mi

nodeSelector: {}

tolerations: []

affinity: {}

现在我已经从以下存储库部署了nginx入口控制器。

git clone https://github.com/samsung-cnct/k2-charts.git

helm install --namespace kube-system --name my-nginx k2-charts / nginx-ingress

下面是nginx-ingress的values.yaml文件,其服务通过LoadBalancer公开。

# Options for ConfigurationMap
configuration:
  bodySize: 64m
  hstsIncludeSubdomains: "false"
  proxyConnectTimeout: 15
  proxyReadTimeout: 600
  proxySendTimeout: 600
  serverNameHashBucketSize: 256

ingressController:
  image: gcr.io/google_containers/nginx-ingress-controller
  version: "0.9.0-beta.8"
  ports:
  - name: http
    number: 80
  - name: https
    number: 443
  replicas: 2

defaultBackend:
  image: gcr.io/google_containers/defaultbackend
  version: "1.3"
  namespace:
  resources:
    memory: 20Mi
    cpu: 10m
  replicas: 1
  tolerations:
   # - key: taintKey
   #   value: taintValue
   #   operator: Equal
   #   effect: NoSchedule

ingressService:
  type: LoadBalancer
#  nodePorts:
#  - name: http
#    port: 8080
#    targetPort: 80
#    protocol: TCP
#  - name: https
#    port: 8443
#    targetPort: 443
#    protocol: TCP
  loadBalancerIP:
  externalName:
  tolerations:
   # - key: taintKey
   #   value: taintValue
   #   operator: Equal

kubectl描述了svc my-nginx

kubectl describe svc nginx-ingress --namespace kube-system
Name:                     nginx-ingress
Namespace:                kube-system
Labels:                   chart=nginx-ingress-0.1.2
                          component=my-nginx-nginx-ingress
                          heritage=Tiller
                          name=nginx-ingress
                          release=my-nginx
Annotations:              helm.sh/created=1526979619
Selector:                 k8s-app=nginx-ingress-lb
Type:                     LoadBalancer
IP:                       10.100.180.127
Port:                     http  80/TCP
TargetPort:               80/TCP
NodePort:                 http  31378/TCP
Endpoints:                External-IP:80,External-IP:80
Port:                     https  443/TCP
TargetPort:               443/TCP
NodePort:                 https  32127/TCP
Endpoints:                External-IP:443,External-IP:443
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

它没有为nginx-ingress创建外部IP地址,而是显示待处理状态。

nginx-ingress          LoadBalancer   10.100.180.127   <pending>     80:31378/TCP,443:32127/TCP   20s

我的ingress.yaml如下

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test-ingress
  labels:
    app: {{ template "demochart.name" . }}
    chart: {{ template "demochart.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - host: test.example.com
    http:
      paths:
      - path: /entity
        backend:
          serviceName: testsvc
          servicePort: 30003

是否可以通过nginx-ingress-controller在自定义Kubernetes集群中实现入口?

0 个答案:

没有答案