Ïê½âgitlabµÄÂþÑÜʽ°²Åżƻ®
ÔÚÏÖ´úÈí¼þ¿ª·¢Àú³ÌÖУ¬°æ±¾¿ØÖÆÊDZز»¿ÉÉÙµÄÒ»ÏîÊÖÒÕ¡£gitÊÇÏÖÔÚ×îÊܽӴýµÄ°æ±¾¿ØÖÆϵͳ֮һ£¬¶øgitlabÔòÊÇÒ»¿î»ùÓÚgitµÄwebÓ¦ÓóÌÐò¡£ÓëÆäËûµÄ°æ±¾¿ØÖÆƽ̨Ïà±È£¬gitlabÌṩÁ˸üÍêÕûµÄ¹¦Ð§£¬°üÀ¨´úÂëÖÎÀí¡¢ci/cd¡¢Àú³ÌÖÎÀíµÈ£¬±»ÆÕ±éÓ¦ÓÃÓÚÆóÒµÖС£
¿ÉÊÇ£¬ÔÚ´ó¹æÄ£µÄ×éÖ¯ÖÐʹÓÃGitlabÓÐһЩÄÑÌâ¡£ÀýÈ磬ÔÚ¸ºÔظßʱ£¬GitlabЧÀÍÆ÷µÄÐÔÄÜ¿ÉÄܱäµÃȱ·¦ÒÔÖ§³ÖÕû¸öÍŶӣ¬Ôì³ÉÁËÎÞ·¨¿ìËÙÏìÓ¦µÄÓû§ÌåÑé¡£½â¾öÕâ¸öÎÊÌâµÄÒªÁìÖ®Ò»ÊÇʹÓÃGitlabÂþÑÜʽ°²ÅÅ¡£
GitlabÂþÑÜʽ°²ÅÅÌṩÁËÒ»ÖÖ¿ÉÀ©Õ¹µÄ½â¾ö¼Æ»®£¬¿ÉÒÔͨ¹ý¶à¸ö½Úµã΢µ÷×ÊÔ´À´¸ÄÉÆÐÔÄÜ¡£Ò»¸öÂþÑÜʽGitlab°²ÅÅ¿ÉÒÔ¿ç¶à¸öЧÀÍÆ÷»òÈÝÆ÷°²ÅÅ£¬Óɶà¸öGitlabʵÀý×é³É£¬²¢ÔÚËüÃÇÖ®¼ä¹²Ïí×ÊÔ´ºÍ¸ºÔØ¡£
ÏÂÃ棬ÎÒ½«ÏÈÈÝÒ»ÖÖ»ùÓÚDocker SwarmµÄGitlabÂþÑÜʽ°²Åżƻ®¡£
×¼±¸ÊÂÇé
ÔÚ×îÏÈ°²ÅÅÇ°£¬ÐèҪ׼±¸ÒÔÏÂÓ²¼þºÍÈí¼þ×ÊÔ´£º
Ä¿½ñµÄGitlabЧÀÍÆ÷
ÓÃÓÚ°²ÅÅÐÂGitlabÈÝÆ÷µÄЧÀÍÆ÷£¨½Úµã£©
×°ÖÃÁËDockerºÍDocker SwarmµÄ½Úµã
°ì·¨Ò»£º³õʼ»¯Swarm
ҪʹÓÃDocker SwarmÀ´ÖÎÀíGitlabÈÝÆ÷£¬±ØÐèÊ×Ïȳõʼ»¯Swarm¡£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÍê³É³õʼ»¯£º
$ docker swarm init
µÇ¼ºó¸´ÖÆ
´ËÏÂÁî»áÌìÉúSwarm ManagerµÄToken£¬ÉÔºó½«Ê¹ÓôËTokenÔÚÆäËû½ÚµãÉϼÓÈëSwarm¡£
°ì·¨¶þ£ºÉèÖó¤ÆÚ»¯´æ´¢
ΪÁËÈ·±£Êý¾ÝµÄÇå¾²ÐÔ£¬ÐèÒª½«GitlabµÄÊý¾Ý³¤ÆÚ»¯´æ´¢µ½´ÅÅÌÉÏ¡£¿ÉÒÔʹÓÃDockerµÄ¡°volume¡±ÏÂÁîÀ´ÊµÏÖÕâÒ»µã¡£ÒÔÏÂÊÇÒ»¸öÔÚÍâµØ´ÅÅÌÉϽ¨ÉèÃûΪ¡°gitlab_config¡±µÄDocker¾íµÄʾÀýÏÂÁ
$ docker volume create --name gitlab_config
µÇ¼ºó¸´ÖÆ
ͬÑù£¬¿ÉÒÔΪGitlabµÄÈÕÖ¾ºÍÊý¾ÝĿ¼½¨ÉèеÄDocker¾í¡£Ê¹ÓÃÒÔÏÂÏÂÁî»®·Ö½¨ÉèÕâÁ½¸ö¾í£º
$ docker volume create --name gitlab_logs $ docker volume create --name gitlab_data
µÇ¼ºó¸´ÖÆ
°ì·¨Èý£º°²ÅÅGitlabÈÝÆ÷
ÏÖÔÚ¿ÉÒÔ°²ÅÅеÄGitlabÈÝÆ÷ÁË¡£ÒÔÏÂÊÇÒ»¸öʾÀýdocker serviceÏÂÁÓÃÓÚÆô¶¯´øÓÐ×Ô½ç˵ѡÏîºÍÅþÁ¬µ½³¤ÆÚ¾íµÄGitlabÈÝÆ÷£º
$ docker service create \ --name gitlab \ --mount source=gitlab_config,target=/etc/gitlab \ --mount source=gitlab_logs,target=/var/log/gitlab \ --mount source=gitlab_data,target=/var/opt/gitlab \ --publish published=80,target=80 \ --publish published=22,target=22 \ gitlab/gitlab-ce:latest
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
°ì·¨ËÄ£º¼ÓÈë½Úµã
ÏÖÔÚ¿ÉÒÔʹÓÃSwarm Manager Token½«ÆäËû½ÚµãÌí¼Óµ½SwarmÖС£Ê×ÏÈʹÓÃÒÔÏÂÏÂÁî»ñÈ¡Token£º
$ docker swarm join-token manager
µÇ¼ºó¸´ÖÆ
¸ÃÏÂÁÊä³öÈçÏÂÄÚÈÝ£º
To add a manager to this swarm, run the following command: docker swarm join --token SWMTKN-...... xxx.xxx.xxx.xxx:2377 To add a worker to this swarm, run the following command: docker swarm join --token SWMTKN-...... xxx.xxx.xxx.xxx:2377
µÇ¼ºó¸´ÖÆ
½«¸ÃÏÂÁÖƲ¢ÔÚÆäËûЧÀÍÆ÷ÉÏÖ´ÐУ¬¼´¿É½«ÆäÌí¼Óµ½SwarmÖС£
°ì·¨Î壺°²ÅŸü¶àÈÝÆ÷
ÒªÀ©Õ¹GitlabÈÝÁ¿£¬¿ÉÒÔÔÚÆäËû½ÚµãÉÏ°²ÅÅÌØÁíÍâGitlabÈÝÆ÷¡£¿ÉÒÔʹÓÃÒÔÏÂÀàËÆÓÚµÚÈý²½µÄdocker serviceÏÂÁîÔÚÆäËû½ÚµãÉÏÆô¶¯ÐÂÈÝÆ÷£º
$ docker service create \ --name gitlab \ --mount source=gitlab_config,target=/etc/gitlab \ --mount source=gitlab_logs,target=/var/log/gitlab \ --mount source=gitlab_data,target=/var/opt/gitlab \ --publish published=80,target=80 \ --publish published=22,target=22 \ gitlab/gitlab-ce:latest
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
×¢ÖØ£¬–nameÑ¡Ïî±ØÐèÉèÖÃΪ¡°gitlab¡±£¬ÒÔ±ãËùÓÐÈÝÆ÷¶¼Äܹ»Ï໥ʶ±ð¡£
½áÂÛ
ʹÓÃDocker SwarmÔÚ¶à¸ö½ÚµãÉÏ°²ÅÅGitlabÈÝÆ÷ÊÇÒ»ÖÖÄܹ»À©Õ¹GitlabÈÝÁ¿²¢Ìá¸ßÐÔÄܵÄÒªÁì¡£GitlabÂþÑÜʽ°²ÅÅ¿ÉÒÔ¿ç¶à¸öЧÀÍÆ÷°²ÅÅ£¬Í¨¹ý¹²Ïí×ÊÔ´ºÍ¸ºÔØÀ´Î¢µ÷×ÊÔ´¡£ÕâʹµÃÍŶÓÄܹ»¸üºÃµØÖÎÀíºÍά»¤Gitlabƽ̨£¬Ìá¸ß²úÆ·¿ª·¢Ð§ÂÊ¡£
ÒÔÉϾÍÊÇÏê½âgitlabµÄÂþÑÜʽ°²Åżƻ®µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡