Входной контроллер nginx не создает IP-адрес балансировщика нагрузки в пользовательском кластере Kubernetes - PullRequest
0 голосов
/ 22 мая 2018

У меня есть пользовательский кластер Kubernetes, созданный с помощью kubeadm.Мой сервис выставляется через порт узла.Теперь я хочу использовать вход для своих сервисов.

Я развернул одно приложение, доступное через NodePort.

Ниже приведен мой файл deploy.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:

Нижеis 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

Ниже приведен файл values.yaml для nginx-ingress, и его сервис предоставляется через 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 description 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>

Он не создает внешний IP-адрес для nginx-ingress и показывает состояние ожидания.

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

Возможно ли реализовать вход в пользовательский кластер Kubernetes через nginx-ingress-controller?

...