AWS Cloud

[Cloud] AWS CI/CD Conf-1 create repogitory in EKS

트리스탄1234 2023. 5. 8. 20:12
728x90
반응형

 

Hello neighbors ^.^ ​

 

Today, I created a repository on Amazon's EKS. Save the image to this repository. I would like to post about how to distribute packages to containers in eks through stored images.

Creat Repogitory

 

1. in the AWS Console, search by entering Codecommit to create a Repository in the Service window..

2. Click Codecommit to create repository.

3. Enter k8s-testconfig in Repository Name, enter config repo in Description and click Create.

반응형

4. Click Repositories on the left side of the screen.

5. Click Create Repository, enter k8s-test and enter image repo in Description and click Create.

6. In the service search bar of the AWS Console, enter EC2 and click.

7. Click instance (running), click baston host, and make ssh connection.

8. Create a directory to store the ssh key using the command below..

sh-4.2$ mkdir ~/.ssh && cd ~/.ssh
sh-4.2$

 

9. Generate a key pair using the command below. Enter the ENTER key without entering any value in the question field.

sh-4.2$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ssm-user/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ssm-user/.ssh/id_rsa.
Your public key has been saved in /home/ssm-user/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:wPafDNQzJsbpfsyLsfOJVcQ3uP87Bf79kvl2S5o3ZcA ssm-user@ip-10-10-61-61.us-west-2.compute.internal
The key's randomart image is:
+---[RSA 2048]----+
| |
| . . o . . |
| + * = +.o |
| . * o + oE. |
| S o. o |
| . * o .. +|
| o O .*+|
| .B o B==|
| +o+ o.*@|
+----[SHA256]-----+
sh-4.2$

 

10. Change the permission of the sssh key using the command below.

sh-4.2$ chmod 600 ~/.ssh/id_rsa
sh-4.2$

 

11. Use the command below to upload the Public Key to AWS and connect it to AWS IAM's gituser.

sh-4.2$ aws iam upload-ssh-public-key \
> --user-name gitUser \
> --ssh-public-key-body file://~/.ssh/id_rsa.pub
{
"SSHPublicKey": {
"UserName": "gitUser",
"SSHPublicKeyId": "APKASJV4OUUHJCBRKUIN",
"Fingerprint": "73:fa:2b:8d:6c:1d:ad:cc:71:12:04:4f:93:cd:52:fd",
"SSHPublicKeyBody": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDW3ZGnOdhG9pV/iTR51FCETHUkcq/FN0hid2gAB1WoFl81SRLrHwW2lWN3kZrOFiqK1RUbB3QzI1tpl7MyLl6u841APdYdI6Kf/XhEakjckFLw3CWAd0XcdL0FVf+BABtnAcvumRSmVaWMVmJJxKrYBjTtEPdf+omVLDL+36r2ypVPEBms5HhVwBMxM0fG+hDPMRuK/6Zho1JTifrn5CEg092EGXSJbeYjBPBcwRxwOqZfOGKffzI6LVt1fAlNs08enZvkj6S9G1igBnd9aDr7mEoxdSGHGa8rMuPtUbr2DHarHOA1nEmiOFYPqaDsoQIH1/ZUqfWKTogucogjNWyD ssm-user@ip-10-10-61-61.us-west-2.compute.internal\n",
"Status": "Active",
"UploadDate": "2023-05-01T10:26:51+00:00"
}
}
sh-4.2$

12. Save the value in the KEYID variable using the command below.

h-4.2$ KEYID=$(aws iam list-ssh-public-keys --user-name gitUser | jq -r '.[] | .[] | .SSHPublicKeyId') && echo $KEYID
APKASJV4OUUHJCBRKUIN

 

13. Now create an ssh configuration file to connect the public key and private key using the command below.

cat <<EOF > ~/.ssh/config
Host git-codecommit.*.amazonaws.com
User ${KEYID}
IdentityFile ~/.ssh/id_rsa
EOF
chmod 700 ~/.ssh/config

 

14. Use the command below to check if you can authenticate to Codecommit. Enter 'yes' when asked if you want to connect.

h-4.2$ ssh git-codecommit.us-west-2.amazonaws.com
The authenticity of host 'git-codecommit.us-west-2.amazonaws.com (52.119.168.71)' can't be established.
RSA key fingerprint is SHA256:0pJx9SQpkbPUAHwy58UVIq0IHcyo1fwCpOOuVgcAWPo.
RSA key fingerprint is MD5:a8:68:53:e3:99:ac:6e:d7:04:7e:f7:92:95:77:a9:77.
Are you sure you want to continue connecting (yes/no)? yes
Please type 'yes' or 'no': yes
Warning: Permanently added 'git-codecommit.us-west-2.amazonaws.com,52.119.168.71' (RSA) to the list of known hosts.
You have successfully authenticated over SSH. You can use Git to interact with AWS CodeCommit. Interactive shells are not supported.Connection to git-codecommit.us-west-2.amazonaws.com closed by remote host.
Connection to git-codecommit.us-west-2.amazonaws.com closed.

 

Now you have created two repositories and created a public key. Then, you need to create a Docker Image through Codepipeline.

We will continue this in the next post. Then have a nice day ^.^

​​

"이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다."

 

728x90
반응형