æè¡é¨ id:sora_h ã§ããä»å㯠v2 ãã AWS ä¸ã§ã®éç¨ã«å¯¾å¿ãã GitHub Enterprise ãããªãã£ã¹ã«ããæ¢åã®ç°å¢ãã AWS ã¸ã¹ã ã¼ãºã«ç§»è¡ãã話ã«ã¤ãã¦èª¬æãã¾ãã
GitHub Enterprise v2
GitHub Enterprise (ä»¥ä¸ GHE) ã¨ã¯ãgithub.com ãèªåã®ç°å¢ã§éç¨ã§ããã¢ãã©ã¤ã¢ã³ã¹ã§ããã¯ãã¯ãããã§ã¯ä¸»ã« GHE ä¸ã§éçºãè¡ã£ã¦ãã¾ãã
å¾æ¥ã¾ã§ GHE ã®å®è¡ç°å¢ã¨ã㦠VMware vSphere, VirtualBox ä¸ã®å®è¡ãããµãã¼ãããã¦ãã¾ããã§ãããã11 æã«ãªãªã¼ã¹ãããã¢ãããã¼ã v2 ãããAWS ã§ã®å®è¡ããµãã¼ãããã¾ããã
ã¯ãã¯ãããã§ã¯å ¨é¢çã« AWS ãå©ç¨ãã¦ãã¾ããããã¾ã¾ã§ GHE ã AWS ä¸ã§åä½ãããäºã¯ã§ãã¾ããã§ããããã®ããããªãã£ã¹å ã« ESXi ç¨ç©çãã·ã³ãç¨æã»ã¡ã³ããã³ã¹ãã¦ãã¾ãããã GHE ã®ç©çãã¹ãã®ã¡ã³ããã³ã¹ã³ã¹ããé«ãäºãåé¡ã§ããã
2014 å¹´ 10 æé ã« GitHub 社ãã AWS ãµãã¼ãã追å ããã GHE v2 ã®ãã¼ã¿ãã¹ãã«æå¾ ããã¾ããããããæ©ä¼ã«ãAWS ã¸ã®ç§»è¡ãåæã«æ¤è¨¼ã»ãã°å ±åã»ç§»è¡ãè¡ãã¾ããã
ESXi æ代ã®æ§æ
ã¾ãã¯ç§»è¡åã®ç°å¢ã«ã¤ãã¦èª¬æãã¾ãã
åè¿°ã®éããGHE ã¯ãªãã£ã¹å ã«è¨ç½®ããã VMware ESXi ãã·ã³ã®ä¸ã§ç¨¼åããã¦ãã¾ããã
ãããããã®ã¾ã¾ã 㨠AWS å´ããã® SSH ã HTTPS ã§ã®ã¢ã¯ã»ã¹ãããã³ GHE ããã AWS å´ã®ãªã½ã¼ã¹ã¸ã¢ã¯ã»ã¹ããäºãã§ãã¾ããããã®ãããESXi ä¸ã« Linux ã® VM ãå¥éç«ã¦ããããã AWS å´ãµã¼ãã¼ã¸ SSH ãã³ãã«ãæãäºã§å¯¾å¿ãã¦ãã¾ããã
å
·ä½çã«ã¯ãssh_config(5) ã® RemoteForward
ãå©ç¨ã㦠AWS å´ãµã¼ãã¼ã®ç¹å®ãã¼ãã GHE ã® 443, 22/tcp ãã¼ãã¸è»¢éããããã«ãã¾ãããåæ§ã«ãGHE ãã¢ã¯ã»ã¹ããå¿
è¦ã®ãã LDAP ãµã¼ãã¼ãSMTP ãµã¼ãã¼ç㯠LocalForward
ã§è»¢éãããããã GHE ã«è¨å®ãã¾ããã
AWS å´ãµã¼ãã¼ããã® git clone ã§å©ç¨ãã ssh ãã¹ãããã³ãã¼ãã®æå®ã¯ãéµã¨ä¸ç·ã«é
å¸ããã ssh_config 㧠Host ...
ããã³ HostName
ãå©ç¨ãã¦ãRemoteForward ãã¦ãããã¼ããå©ç¨ããããã«è¨å®ãã¦ãã¾ãããå°ãé
å¸ã«ã¯ puppet ãå©ç¨ãã¦ãã¾ãã
ã¾ããéçºè
ããªãã£ã¹å¤ã®ãããã¯ã¼ã¯ãã SSH access ãå©ç¨ããéã«ã¯ãAWS å
ã® remote forwarded port ã¸æ¥ç¶ããããã«ã ssh_config ã® ProxyCommand
ãå©ç¨ããè¨å®ãã¡ã¤ã«ãæä¾ãã¦ãã¾ããã
å¤é¨ããã® HTTPS ã§ã®ã¢ã¯ã»ã¹ã¯ãGHE ã® 443 ã«å¯¾å¿ãããã¼ãã« reverse proxy ãã¤ã¤ãå¤é¨ãããã¯ã¼ã¯ã®å ´å㯠HTTP èªè¨¼ãããã Apache ã稼åããããµã¼ãã¼ãç¨æããå¤é¨ãã GHE ã® FQDN ã DNS ã§å¼ããæã¯ãã®ãµã¼ãã¼ã® IP ã¢ãã¬ã¹ãè¿ãããã«ãªã£ã¦ãã¾ãã (ãã® https reverse proxy ã¯ä»¥é github-proxy ã¨å¼ç§°ãã¾ã)
以ä¸ã移è¡å ã®ç°å¢ã§ããã
ä¸ã¤ãGHE å°å ¥å½æã«ãªããç¾å¨å©ç¨ã§ããè¨åã¨ãã¦åå¨ããã®ããAWS VPC ã¨ã®æ ç¹é VPN ããªãã£ã¹ã¨ã®éã§ç¢ºç«ãããäºã§ãã移è¡ã«éãã¦ãSSH ãã³ãã«ããæ ç¹é VPN ãã¼ã¹ã¸ã®åãæ¿ããè¡ãäºã«ãªãã¾ããã
移è¡ã®è¦ä»¶
ã¾ãã¯æ¥åã«æ¯éãåºããã«ç§»è¡ãè¡ãäºãæ±ãããã¾ããã
ã¾ãããã®ã¿ã¤ãã³ã°ã§ GHE å°å
¥ä»¥æ¥å©ç¨ãã¦ãã FQDN ãå¤æ´ããäºã«ãªãã¾ãããFQDN ããã®ã¾ã¾ã§ããã°ãåè¿°ã® RemoteForward
ã® ssh_config ã ã対å¿ã㦠DNS ãåãæ¿ããã ãã§ç§»è¡ãå®äºãã¾ãã
ã§ãããFQDN ãå¤æ´ãããããæ§ URL ãã®ã¾ã¾ã§ã® git clone, http access ããªãã¤ã¬ã¯ãçã§å¯¾å¿ããã¹ã ã¼ãºã«ç§»è¡ã§ããäºã追å ã®è¦ä»¶ã«ãªãã¾ããã
移è¡ã®æé
移è¡ã¯ä¸è¨ã®æé ã§è¡ãäºã«ãã¾ããã
- ã¡ã³ããã³ã¹ã¦ã£ã³ãã¦ã決ããäºåã«ç¤¾å ã¸ã¢ãã¦ã³ã¹ãæµãã¦å¨ç¥ãã
- å½æ¥ãåºç¤¾ãã¦æéã«ãªã£ããæ§ GHE ãã¡ã³ããã³ã¹ã¢ã¼ãã«å ¥ãã
- æ§ GHE ã® ghe-backup ãè¡ã
- å®äºæ¬¡ç¬¬ãæ° GHE ã« ghe-restore ãã
- proxy ã§æ§ GHE ã® FQDN ãæ° GHE ã® FQDNã«ãªãã¤ã¬ã¯ããããè¨å®ã«åãæ¿ãã
- æ§ GHE ã® DNS ãæ§ GHE èªä½ãã github-proxy ã«åãæ¿ãã¦ãTTL ãå¾ ã¤
- æ° GHE ã®ã¡ã³ãã¢ã¼ããå¤ã
ä¸æºå
ããã¯ã¢ãã
ããã¯ã¢ããã§ã¯å¾æ¥ããå ¬å¼ãã¼ã«ã§ãã github/backup-utils ãå©ç¨ãã¦ãã¾ããã å ã ããã¯ã¢ãã㯠ESXi ä¸ã®å¥ä»®æ³ãã·ã³ã§å®è¡ãã¦ãã¾ããããããã¯ã¢ããå ãã¾ã AWS ã¸ç§»è¡ããã¤ã³ã¿ã¼ãããçµç±ã§ã®ããã¯ã¢ããã«åãæ¿ãã¾ããããã®æã®çµè·¯ã¯ VPC ã¨ã®æ ç¹é VPN ãå©ç¨ãã¦ãã¾ãã
移è¡ã¾ã§ã®éãèªåããã¯ã¢ããå®äºå¾ã« AWS ä¸ã«ç«ã¦ã¦ãã GHE ã®ã¤ã³ã¹ã¿ã³ã¹ã¸ãªã¹ãã¢ããããã«è¨å®ãããªãã¹ãææ°ã®ãã¼ã¿ãã¤ãã«æ° GHE ã¸åæãããããã«ãã¾ããã
github-proxy ã®æ° FQDN 対å¿
github-proxy ã¯ä»è¿ããã ãªã¯ã¨ã¹ãã remote port forward ããã HTTPS ãã¼ãã¸ãªãã¼ã¹ãããã·ããå¿ è¦ã«å¿ã㦠BASIC èªè¨¼ãè¦æ±ããã¨ãããµã¼ãã¼ã§ããã
移è¡ã«éããã¾ãæåã¯ãªã¯ã¨ã¹ãã«åããã¦æ§ãã¡ã¤ã³ã¯æ§ GHEãæ°ãã¡ã¤ã³ã¯æ° GHE ã¸ãªãã¼ã¹ãããã·ããããã«è¨å®ãã¾ããã 移è¡å¾ã«å©ç¨ããæ§ãã¡ã¤ã³ã®ãªã¯ã¨ã¹ããæ°ãã¡ã¤ã³ã¸ãªãã¤ã¬ã¯ãããè¨å®ã®æºåãè¡ãã¾ããã
移è¡å¾ã¯ç¤¾å ããããªãã¤ã¬ã¯ãç¨ã«ãæ§ãã¡ã¤ã³ã®ã¬ã³ã¼ãã github-proxy ã¸åããè¨ç»ã®ãããSSH (port 22) ã¸ã®ãã©ãã£ãã¯ãæ° GHE ã¸è»¢éãã stone ãèµ·åãã¾ãããstone ã«ã¤ãã¦ã¯ã¢ã¯ã»ã¹ã社å (VPN çµç±) ã« security group ã§å¶éãã¾ããã
æ¢åã®ãµã¼ãã¼ãä¸é¨ã®éçºè åã ssh_config ã¸ã®å¯¾å¿
åè¿°ã®ããã«æ¢åã®ãµã¼ãã¼ã¨ä¸é¨ã®éçºè ã«é å¸ãã¦ãã ssh_config ã¯ãGHE ãç¹å®ãµã¼ãã¼ä¸ã® remote port forward ããã port ãåç §ããããã«è¨å®ããã¦ãã¾ããã¾ããssh_config ãæã£ããµã¼ãã¼ã¯å¤§éã«åå¨ããããã移è¡å¾ãgit remote ã® url ãå¤æ´ãããæ°è¨å®ãåæ ãããã¾ã§ã¢ã¯ã»ã¹ãããã³ã«ã¨ã©ã¼ã¨ããã®ã¯é¿ãããã¨ããè¦ä»¶ãããã¾ããã
ãã®ãããæ° GHE + æ° FQDN ã® ssh_config ã¯ç§»è¡åã«è¿½å ãã¦ããããã¾ã¾ã§ã® ssh_config ããã®ã¾ã¾å©ç¨ã§ããããã移è¡å¾ã¯ remote port forward ãã¦ãããã¼ããæ° GHE ã® port 22 ã¸ãã©ãã£ãã¯ã転éãã stone ã«ç½®ãæãã¾ããããã®å¾ãæ§ãã¹ãã®è¨å®ãåé¤ããæ° GHE è¨å®ã® Host
ã«æ§ GHE ã® FQDN ã追å ãã¾ããã
ãã®ãããªæé ããããããè¸ãäºã«ãããFQDN å¤æ´ã«ããã¨ã©ã¼ãæå°éã«çããäºãã§ãã¾ãããAPI ãå©ç¨ãã¦ããç®æã«ã¤ãã¦ã¯ãªãã¤ã¬ã¯ãã«å¯¾å¿ã§ãããæå㧠URL ãå¤æ´ããã¾ã§åä½ããªãã¨ãã£ãã±ã¼ã¹ãããã¾ããããéçºè ããã® HTTPS ã¢ã¯ã»ã¹ããµã¼ãä¸ã® git clone/pull ã«ã¤ãã¦ã¯ã¨ã©ã¼ãªã移è¡ã¨ FQDN å¤æ´ãéæãã¾ããã
移è¡å¾
git remote URL ã®åãæ¿ããä¿ã
FQDN ãå¤æ´ãããããgit remote ã®è¨å®ãæ°ãã¡ã¤ã³ã«å¤æ´ãã¦ãããå¿ è¦ãããã¾ããã以ä¸ã® ssh_config ãå©ç¨ããã¨æ¥½ã§ãããã¨ç¤¾å ããã°ã§å¨ç¥ããããã¾ããã
Host æ§ãã¡ã¤ã³ Hostname æ°ãã¡ã¤ã³ PermitLocalCommand yes LocalCommand bash -c 'for remote in $(git remote -v|grep "@æ§ãã¡ã¤ã³"|cut -f 1|sort|uniq); do url=$(git config remote.${remote}.url | sed -e "s/@æ§ãã¡ã¤ã³/@æ°ãã¡ã¤ã³/"); echo "warn: set-url ${remote} ${url}" >/dev/stderr; git remote set-url ${remote} ${url}; done'
ssh_config ã® LocalCommand ãå©ç¨ãã¦ãæ§ãã¡ã¤ã³ã®ååã§æ¥ç¶ã試ã¿ãæã« git remote set-url ãåæã«å¼ãã§ããã¾ãã
ã¾ã¨ã
æ¬è¨äºã§ã¯ãã©ã®ããã«ã¯ãã¯ãããã GitHub Enterprise v2 + AWS ã«ç§»è¡ãã¤ã¤ãGHE ã®åä½ FQDN ãæå°éã®ã¨ã©ã¼ã§å¤æ´ãããã解説ãã¾ããã
(ãªããåç㯠GitHub ãããã¼ã¿ãã¹ãååã® gift ã¨ãã¦é ãã Octocat Figurine ã§ã (ãããã)ãThank you <3)