Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

Agent websocket issue #67

Open
XionZhao opened this issue Nov 28, 2018 · 2 comments
Open

Agent websocket issue #67

XionZhao opened this issue Nov 28, 2018 · 2 comments

Comments

@XionZhao
Copy link

I want to add a configuration to haproxy.cfg
The

apiVersion: v1
kind: ConfigMap
metadata:
  name: haproxy-conf
  namespace: test-keep
data:
  haproxy.cfg: |
    global
    stats         socket /tmp/haproxy mode 600 level admin
    maxconn       100000

    defaults
      maxconn       100000
      timeout connect 1s
      timeout client 1200s
      timeout server 1200s
      timeout tunnel        3600s
      timeout http-keep-alive  1s
      timeout http-request    15s
      timeout queue           30s

    listen stats
      bind      :1936
      mode      http
      stats     uri /
      stats     realm Haproxy\ Statistics
      stats     enable
      timeout   connect 5000
      timeout   client 5000
      timeout   server 5000

I created a configmap of haproxy. CFG, but it was not successful. May I ask how to operate it if I want to increase the configuration of haproxy

kube-keepalived-vip-configmap configuration

apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  labels:
    name: kube-keepalived-vip
  name: kube-keepalived-vip
  namespace: test-keep
spec:
  selector:
    matchLabels:
      name: kube-keepalived-vip
  template:
    metadata:
      labels:
        name: kube-keepalived-vip
    spec:
      containers:
      - image: aledbf/haproxy-self-reload:0.2
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /
            port: 1936
            scheme: HTTP
          initialDelaySeconds: 30
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 5
        name: haproxy-self-reload
        volumeMounts:
        - mountPath: /etc/haproxy
          name: haproxy
      - args:
        - --services-configmap=keepalived/vip-configmap
        - --proxy-protocol-mode=true
        env:
        - name: POD_NAME
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.name
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.namespace
        image: aledbf/kube-keepalived-vip:0.29
        imagePullPolicy: IfNotPresent
        name: kube-keepalived-vip
        securityContext:
          privileged: true
        volumeMounts:
        - mountPath: /lib/modules
          name: modules
          readOnly: true
        - mountPath: /dev
          name: dev
        - mountPath: /etc/haproxy
          name: haproxy
      dnsPolicy: ClusterFirst
      hostNetwork: true
      restartPolicy: Always
      serviceAccount: kube-keepalived-vip
      serviceAccountName: kube-keepalived-vip
      terminationGracePeriodSeconds: 30
      volumes:
      - hostPath:
          path: /lib/modules
          type: ""
        name: modules
      - hostPath:
          path: /dev
          type: ""
        name: dev
      - configMap:
          name: haproxy-conf
        name: haproxy

@elemental-lf
Copy link
Contributor

elemental-lf commented Nov 28, 2018

You need to mount a ConfigMap over the HAProxy template(!). But you'd need to do some trickery with subPath as the HAProxy template is not in a directory of its own. As a consequence changes to the ConfigMap after start of the container won't be reflected in it because a bind mount is used to implement the subPath feature. Define a volume like this:

- name: haproxy-tmpl
  configMap:
    name: kube-apiserver-vip-haproxy-tmp
    defaultMode: 0422

And reference it like this in the kube-keepalived-d/keepalived container definition:

- name: haproxy-tmpl
  mountPath: /haproxy.tmpl
  subPath: haproxy.tmpl
  readOnly: true

The key name in the ConfigMap needs to be haproxy.tmpl.
You could also derive a new image and replace /haproxy.tmpl with a new a file or a symlink to a separate directory where you then mount the ConfigMap.

@XionZhao
Copy link
Author

The above method is available and is currently in effect in my environment, thank you 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants