1.在OperatorHub搜索GitLab
点击install
Update approval 改为 Manual
2.Create GitLab
kind: GitLab
apiVersion: apps.gitlab.com/v1beta1
metadata:name: gitlabnamespace: gitlab-system
spec:chart:values:certmanager:install: falseglobal:hosts:domain: example.com ## 这里替换成自己的hostSuffix: nullingress:configureCertmanager: falsetls:secretName: gitlab-tlspostgresql:primary:extendedConfiguration: max_connections = 200version: 8.9.1
等待安装完成即可。
3.集成LDAP用户
新增configmap
kind: ConfigMap
apiVersion: v1
metadata:name: ldap-confignamespace: gitlab-system
data:set-config: |-#!/bin/bashset -eo pipefailTEMPLATE_DIRECTORY="$1"CONFIG_DIRECTORY="${2:-$1}"if [ -z "$TEMPLATE_DIRECTORY" ]; thenecho 'usage: set-config <template_directory> [<config_directory>]'exit 1fishopt -s nullglob # Don't enter empty for loopsif command -v erb &> /dev/null; thenecho "Begin parsing .erb templates from $TEMPLATE_DIRECTORY"for template in ${TEMPLATE_DIRECTORY}/*.erb; dooutput_file="${CONFIG_DIRECTORY}/$(basename $template '.erb')"echo "Writing $output_file"erb -U -r yaml -r json -r fileutils "$template" > "$output_file"donefiif command -v gomplate &> /dev/null; thenecho "Begin parsing .tpl templates from $TEMPLATE_DIRECTORY"for template in ${TEMPLATE_DIRECTORY}/*.tpl; dooutput_file="${CONFIG_DIRECTORY}/$(basename $template '.tpl')"echo "Writing $output_file"gomplate --left-delim '{%' --right-delim '%}' --file "${template}" --out "${output_file}"donefiif [ "$CONFIG_DIRECTORY" != "$TEMPLATE_DIRECTORY" ]; thenecho "Copying other config files found in $TEMPLATE_DIRECTORY to $CONFIG_DIRECTORY"for configfile in ${TEMPLATE_DIRECTORY}/*.{yml,yaml,toml,rb,json}; doecho "Copying $(basename $configfile) into ${CONFIG_DIRECTORY}"cp "$configfile" "$CONFIG_DIRECTORY/"donefishopt -u nullglobconfig_file="/srv/gitlab/config/gitlab.yml"# 使用 sed 删除 ldap 配置中的 'enabled: false' 行sed -i '/ldap:/,/^$/ { /enabled: false/ { d } }' "$config_file"# 使用 echo 追加新的 ldap 配置cat <<EOL >> "$config_file"ldap:enabled: trueservers:main:label: ldaphost: ldap.example.comport: 636uid: 'sAMAccountName'encryption: 'simple_tls'verify_certificates: falsebase: 'xxxx'user_filter: ''bind_dn: 'xxx'admin_group: ''password: 'xxx'EOLecho "LDAP 配置已更新。"
ldap配置根据你的实际情况进行更改。
修改deployment 的yaml,把此ldap-config的set-config挂载到gitlab-webservice-default的/scripts/set-config路径上。
kind: Deployment
apiVersion: apps/v1
metadata:name: gitlab-webservice-default
spec:template:metadata:spec:volumes:- name: ldap-configconfigMap:name: ldap-config containers:- name: webservicevolumeMounts:- name: ldap-configmountPath: /scripts/set-configsubPath: set-config
这样gitlab就集成了ldap