前言

镜像使用开源镜像 bitnami/openldap:latest。

1、创建一个deploy

apiVersion: apps/v1
kind: Deployment
metadata:
  name: openldap
  namespace: zeus
spec:
  replicas: 1
  selector:
    matchLabels:
      app: openldap
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: openldap
    spec:
      containers:
      - env:
        - name: LDAP_ADMIN_USERNAME
          value: admin
        - name: LDAP_ADMIN_PASSWORD
          value: Ab123456
        - name: LDAP_USERS
          value: customuser
        - name: LDAP_PASSWORDS
          value: Ab123456
        - name: LDAP_ROOT
          value: dc=harmonycloud,dc=cn
        image: 10.10.101.22:8443/middleware/openldap:v1.0
        imagePullPolicy: Always
        name: openldap
        ports:
        - containerPort: 1389
          name: service
          protocol: TCP
        resources:
          limits:
            cpu: "1"
            memory: 2Gi
          requests:
            cpu: "1"
            memory: 2Gi
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30

2、使用NodePort service暴露服务

apiVersion: v1
kind: Service
metadata:
  name: ldap
  namespace: zeus
spec:
  clusterIP: 10.105.111.220
  externalTrafficPolicy: Cluster
  ports:
  - nodePort: 32691
    port: 1389
    protocol: TCP
    targetPort: service
  selector:
    app: openldap
  sessionAffinity: None
  type: NodePort
status:
  loadBalancer: {}

3、使用ApacheDirectoryStudio访问ldap

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐