{"id":429,"date":"2023-12-25T20:58:47","date_gmt":"2023-12-25T20:58:47","guid":{"rendered":"https:\/\/devopsopen.com\/?p=429"},"modified":"2023-12-25T21:15:09","modified_gmt":"2023-12-25T21:15:09","slug":"kong","status":"publish","type":"post","link":"https:\/\/devopsopen.com\/index.php\/2023\/12\/25\/kong\/","title":{"rendered":"Kong"},"content":{"rendered":"<h2>Installation Kong<\/h2>\n<h3>Installation de la base Postgres<\/h3>\n<p>Soit l'installation est sur le cluster ou sur une VM<\/p>\n<h3>Cr\u00e9ation des cl\u00e9s cluster<\/h3>\n<pre><code>openssl req -new -x509 -nodes -newkey ec:&lt;(openssl ecparam -name secp384r1) \\\n-keyout .\/cluster.key -out .\/cluster.crt \\\n-days 1095 -subj &quot;\/CN=kong_clustering&quot;\n\nkubectl create secret tls kong-cluster-cert --cert=.\/cluster.crt --key=.\/cluster.key -n kong<\/code><\/pre>\n<h3>Installation du controle Plane<\/h3>\n<p>En choisissant la base sur une VM voici le yaml qu'il faut appliquer <\/p>\n<pre><code>apiVersion: v1\nkind: ServiceAccount\nmetadata:\n  namespace: kong\n  name: kong\n  labels:\n    app: kong\n---\napiVersion: rbac.authorization.k8s.io\/v1\nkind: Role\nmetadata:\n  namespace: kong\n  name: kong\n  labels:\n    app: kong\nrules:\n  - apiGroups:\n      - &quot;&quot;\n    resources:\n      - secrets\n    verbs:\n      - get\n---\napiVersion: rbac.authorization.k8s.io\/v1\nkind: RoleBinding\nmetadata:\n  namespace: kong\n  name: kong\n  labels:\n    app: kong\nroleRef:\n  apiGroup: rbac.authorization.k8s.io\n  kind: Role\n  name: kong\nsubjects:\n  - kind: ServiceAccount\n    namespace: kong\n    name: kong\n---\napiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  namespace: kong\n  name: kong-control-plane\n  labels:\n    app: kong-control-plane\nspec:\n  selector:\n    matchLabels:\n      app: kong-control-plane\n  strategy:\n    rollingUpdate:\n      maxSurge: 1\n      maxUnavailable: 0\n    type: RollingUpdate\n  template:\n    metadata:\n      annotations:\n        k8s.konghq.com\/sidecar-inject: &quot;false&quot;\n        prometheus.io\/port: &quot;8001&quot;\n        prometheus.io\/scrape: &quot;true&quot;\n      labels:\n        app: kong-control-plane\n    spec:\n      serviceAccountName: kong\n      initContainers:\n        - name: kong-migration-up\n          image: kong\n          imagePullPolicy: IfNotPresent\n          env:\n            - name: KONG_DATABASE\n              value: postgres\n            - name: KONG_PG_USER\n              value: toto\n            - name: KONG_PG_PASSWORD\n              value: toto\n            - name: KONG_PG_HOST\n              value: 111.11.111.111\n            - name: KONG_NGINX_WORKER_PROCESSES\n              value: &quot;1&quot;\n          command: [ &quot;\/bin\/sh&quot;, &quot;-c&quot;, &quot;kong migrations up &amp;&amp; kong migrations finish&quot; ]\n      volumes:\n      - name: tls-volumekong\n        secret:\n          secretName: kong-cluster-cert\n      containers:\n        - name: kong-control-plane\n          volumeMounts:\n          - name: tls-volumekong\n            mountPath: \/etc\/secrets\/kong-cluster-cert\n          image: kong\n          imagePullPolicy: IfNotPresent\n          env:\n            - name: KONG_ROLE\n              value: control_plane\n            - name: KONG_DATABASE\n              value: postgres\n            - name: KONG_PG_USER\n              value: toto\n            - name: KONG_PG_PASSWORD\n              value: toto\n            - name: KONG_PG_HOST\n              value: 111.11.111.111\n            - name: KONG_LOG_LEVEL\n              value: notice\n            - name: KONG_ADMIN_ACCESS_LOG\n              value: \/dev\/stdout\n            - name: KONG_PROXY_ERROR_LOG\n              value: \/dev\/stderr\n            - name: KONG_ADMIN_ERROR_LOG\n              value: \/dev\/stderr\n            - name: KONG_ADMIN_LISTEN\n              value: 0.0.0.0:8001\n            - name: KONG_PROXY_LISTEN\n              value: &#039;off&#039;\n            - name: KONG_NGINX_WORKER_PROCESSES\n              value: &quot;1&quot;\n            - name: KONG_CLUSTER_CERT\n              value: \/etc\/secrets\/kong-cluster-cert\/tls.crt\n            - name: KONG_CLUSTER_CERT_KEY\n              value: \/etc\/secrets\/kong-cluster-cert\/tls.key\n          ports:\n            - name: cluster-http\n              containerPort: 8005\n            - name: cluster-tele\n              containerPort: 8006\n            - name: admin-http\n              containerPort: 8001\n          livenessProbe:\n            failureThreshold: 3\n            httpGet:\n              path: \/status\n              port: 8001\n              scheme: HTTP\n            initialDelaySeconds: 30\n            periodSeconds: 10\n            successThreshold: 1\n            timeoutSeconds: 1\n          readinessProbe:\n            failureThreshold: 3\n            httpGet:\n              path: \/status\n              port: 8001\n              scheme: HTTP\n            periodSeconds: 10\n            successThreshold: 1\n            timeoutSeconds: 1\n---\napiVersion: v1\nkind: Service\nmetadata:\n  namespace: kong\n  name: kong-control-plane\nspec:\n  type: ClusterIP\n  ports:\n    - port: 8001\n  selector:\n    app: kong-control-plane\n---\napiVersion: v1\nkind: Service\nmetadata:\n  namespace: kong\n  name: kong-cluster-svc\nspec:\n  type: ClusterIP\n  ports:\n    - port: 8005\n  selector:\n    app: kong-control-plane\n---\napiVersion: batch\/v1\nkind: Job\nmetadata:\n  namespace: kong\n  name: kong-control-plane-bootstrap\n  labels:\n    app: kong-control-plane-bootstrap\nspec:\n  template:\n    metadata:\n      name: kong-control-plane-bootstrap\n      labels:\n        app: kong-control-plane\n    spec:\n      containers:\n        - name: kong-migration-boostrap\n          image: kong\n          imagePullPolicy: IfNotPresent\n          env:\n            - name: KONG_DATABASE\n              value: postgres\n            - name: KONG_PG_USER\n              value: toto\n            - name: KONG_PG_PASSWORD\n              value: toto\n            - name: KONG_PG_HOST\n              value: 111.11.111.111\n            - name: KONG_NGINX_WORKER_PROCESSES\n              value: &quot;1&quot;\n          command: [ &quot;kong&quot;, &quot;migrations&quot;, &quot;bootstrap&quot; ]\n      restartPolicy: OnFailure<\/code><\/pre>\n<h3>Installtation du dataPlane<\/h3>\n<p>Create dataplane with this script yaml<\/p>\n<pre><code>apiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  namespace: kong\n  name: kong-data-plane\n  labels:\n    app: kong-data-plane\nspec:\n  replicas: 1\n  selector:\n    matchLabels:\n      app: kong-data-plane\n  strategy:\n    rollingUpdate:\n      maxSurge: 1\n      maxUnavailable: 0\n    type: RollingUpdate\n  template:\n    metadata:\n      annotations:\n        k8s.konghq.com\/sidecar-inject: &quot;false&quot;\n      labels:\n        app: kong-data-plane\n    spec:\n      volumes:\n      - name: tls-volumekong\n        secret:\n          secretName: kong-cluster-cert\n      containers:\n      - name: kong-data-plane\n        volumeMounts:\n          - name: tls-volumekong\n            mountPath: \/etc\/secrets\/kong-cluster-cert\n        image: kong:latest\n        imagePullPolicy: IfNotPresent\n        env:\n          - name: KONG_ROLE\n            value: data_plane\n          - name: KONG_DATABASE\n            value: &#039;off&#039;\n          - name: KONG_PROXY_ACCESS_LOG\n            value: \/dev\/stdout\n          - name: KONG_PROXY_ERROR_LOG\n            value: \/dev\/stderr\n          - name: KONG_CLUSTER_CONTROL_PLANE\n            value: 10.49.47.118:8005\n          - name: KONG_STATUS_LISTEN\n            value: 0.0.0.0:8001\n          - name: KONG_CLUSTER_CERT\n            value: \/etc\/secrets\/kong-cluster-cert\/tls.crt\n          - name: KONG_CLUSTER_CERT_KEY\n            value: \/etc\/secrets\/kong-cluster-cert\/tls.key\n        ports:\n          - name: data-http\n            containerPort: 8000<\/code><\/pre>\n<h3>Liens utils<\/h3>\n<p>Vars Postgres : <a href=\"https:\/\/docs.konghq.com\/gateway\/latest\/install\/docker\/\">https:\/\/docs.konghq.com\/gateway\/latest\/install\/docker\/<\/a><br \/>\nDataplane : <a href=\"https:\/\/github.com\/Kong\/kong-dist-kubernetes\/blob\/master\/kong-ingress-data-plane-postgres.yaml\">https:\/\/github.com\/Kong\/kong-dist-kubernetes\/blob\/master\/kong-ingress-data-plane-postgres.yaml<\/a><\/p>\n<p>ControlPlane : <a href=\"https:\/\/github.com\/Kong\/kong-dist-kubernetes\/blob\/master\/kong-control-plane-postgres.yaml\">https:\/\/github.com\/Kong\/kong-dist-kubernetes\/blob\/master\/kong-control-plane-postgres.yaml<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Installation Kong Installation de la base Postgres Soit l&#8217;installation est sur le cluster ou sur une VM Cr\u00e9ation des cl\u00e9s cluster openssl req -new -x509 -nodes -newkey ec:&lt;(openssl ecparam -name secp384r1) \\ -keyout .\/cluster.key -out .\/cluster.crt \\ -days 1095 -subj &quot;\/CN=kong_clustering&quot; kubectl create secret tls kong-cluster-cert &#8211;cert=.\/cluster.crt &#8211;key=.\/cluster.key -n kong Installation du controle Plane En choisissant la base sur une VM voici le yaml qu&#8217;il faut appliquer apiVersion: v1 kind: ServiceAccount metadata: namespace: kong name: kong labels: app: kong &#8212; apiVersion: rbac.authorization.k8s.io\/v1 kind: Role metadata: namespace: kong name: kong labels: app: kong rules: &#8211; apiGroups: &#8211; &quot;&quot; resources: &#8211; secrets\u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":""},"categories":[12],"tags":[],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":5}},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"admin","author_link":"https:\/\/devopsopen.com\/index.php\/author\/admin_bak\/"},"uagb_comment_info":37,"uagb_excerpt":"Installation Kong Installation de la base Postgres Soit l'installation est sur le cluster ou sur une VM Cr\u00e9ation des cl\u00e9s cluster openssl req -new -x509 -nodes -newkey ec:&lt;(openssl ecparam -name secp384r1) \\ -keyout .\/cluster.key -out .\/cluster.crt \\ -days 1095 -subj &quot;\/CN=kong_clustering&quot; kubectl create secret tls kong-cluster-cert --cert=.\/cluster.crt --key=.\/cluster.key -n kong Installation du controle Plane En&hellip;","_links":{"self":[{"href":"https:\/\/devopsopen.com\/index.php\/wp-json\/wp\/v2\/posts\/429"}],"collection":[{"href":"https:\/\/devopsopen.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devopsopen.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devopsopen.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/devopsopen.com\/index.php\/wp-json\/wp\/v2\/comments?post=429"}],"version-history":[{"count":4,"href":"https:\/\/devopsopen.com\/index.php\/wp-json\/wp\/v2\/posts\/429\/revisions"}],"predecessor-version":[{"id":433,"href":"https:\/\/devopsopen.com\/index.php\/wp-json\/wp\/v2\/posts\/429\/revisions\/433"}],"wp:attachment":[{"href":"https:\/\/devopsopen.com\/index.php\/wp-json\/wp\/v2\/media?parent=429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devopsopen.com\/index.php\/wp-json\/wp\/v2\/categories?post=429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devopsopen.com\/index.php\/wp-json\/wp\/v2\/tags?post=429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}