15 Nisan 2022 Cuma

GitOps

Giriş
Açıklaması şöyle
The idea behind GitOps is to have all the necessary infrastructure components up and running before pushing code to production.
...
It basically involves Git to store all your manifest files and Kubernetes to deploy the application.


13 Nisan 2022 Çarşamba

Amazon Web Service (AWS) Identity and Access Management (IAM)

Giriş
Açıklaması şöyle
- Configure and manage users.
- This service is an integral part of AWS.
IAM Bileşenleri
1. Users
Açıklaması şöyle
Users are individual AWS accounts that can be granted access to your AWS resources. You can assign users specific permissions with policies or assign them to groups so they inherit the group's permissions. This means you can give different levels of access to certain services and control what types of actions each user is able to perform. 
2. Groups
Açıklaması şöyle
Groups are collections of users that share the same set of permissions. When you assign a policy to a group, all members of the group will receive those same permissions. AWS IAM groups provide a secure and consistent way for teams with varying needs and roles to access cloud resources without needing multiple administrative logins.
3. Policies
Açıklaması şöyle
Policies define what actions a user or service may take on AWS resources. They are written using JSON and contain one or more statements that control who has access, what actions they may take, and which resources they can access. Policies are assigned to users or groups and govern how they interact with AWS resources, such as Amazon S3 buckets and EC2 instances. 
Örnek
Şöyle yaparız
{
  "Version": "2012-10-17",
  "Statement": {
    "Effect": "Allow",
    "Action": "s3:ListBucket",
    "Resource": "arn:aws:s3:::example_bucket"
  }
}
4. Roles
Açıklaması şöyle
Roles are similar to groups. They also have associated policies, but roles are not tied to a particular user or group. They can be used to grant limited access to applications and users, allowing for greater security and control over resources. For example, an IAM Role can be assigned to an IAM user, and this role will determine what part of the AWS environment they have access to, such as EC2 instances or S3 buckets. Each IAM Role also includes a set of permissions rules which further limit what user activities can be performed within that role's scope. 
Resource-Based Policy ve IAM Farkı
Açıklaması şöyle
A resource-based policy is a mechanism available on several types of AWS resources that allows granting access directly to the resource. In contrast to an IAM policy, which can only grant permissions to the principals managed in the account, a resource-based policy allows granting access to principals outside the account.
Örnek
Şöyle yaparız
{
  "Sid": "AllowAccessToExternalAccount",

  "Effect": "Allow",

  "Principal": {

    "AWS": "arn:aws:iam::<ACCOUNT_ID>:root"

  },

  "Action": [

     "<service>:<PermissionName>"

    ],

  "Resource": "<RESOURCE_ARN>"

 }
Açıklaması şöyle
In this case, the “Principal” field is specified with a configuration that allows another account, via IAM policies, to grant access to the principals in it. 
Ancak şöyle yapmak tehlikeli. Bu durumda AWS içindeki herkese hak verilmiş oluyor
{
  "AWS": "*"
}

IAM Örnekleri
Örnek - Kullanıcı Yaratma
Adımlar şöyle
- Login to your AWS account and open IAM service. Click Users under Access Management.
- Click Add users button to set the user details and credential type as shown below.
- Enter jmeter-s3-access in User name and check Access key - Programmatic access.
- This user will have access to the AWS service programmatically, not from the user console. Click Next: Permissions.
- In the Set permissions section, click Attach existing policies directly, and filter the policies of S3 by typing s3.
- For the demonstration purpose, let us go with AmazonS3FullAccess. Check AmazonS3FullAccess and then click Next: Tags. But for the production server, follow the zero trust framework.
- Adding tags is optional, but it is recommended to have relevant key-pair values.
- Click Review and then click on Create user.
- Copy the Access key ID and Secret access key to a secured location. Alternatively, you can download the .csv file.
Örnek - Access Key Yaratma
Adımlar şöyle
Go to Services -> IAM -> Users -> Your-User-Name -> Security Credentials -> Create Access Key.
Örnek - Role Yaratma
Adımlar şöyle. Burada SNS'i tüketecek Lambda için role yaratılıyor
- Open the IAM console and click on Roles.
- Click on Create Role.
- Select Lambda from the use cases list and click next.
- In attach permission policies, search for SNS.
- Choose Read-Only Access from the list.
- Finish the steps by given the role a descriptive name.
Önce "services" seçiliyor. Daha sonra bu service için "use cases" seçiliyor. Burada EKS için iki tane "use case" şöyle


Örnek - Role Yaratma
Adımlar şöyle
Search for IAM Service in the search bar.
On to right side
Access Management -> Roles
Click on Create role.
Select type of trusted entity as AWS Service
Choose a use case as EC2.
Click on the Next: Permissions button
On the permission page, select AmazonEC2RoleforAWSCodeDeploy policy and click on the Next: Tags button.
Leave the Tags tab as it is optional and click on the Next: Review button.
Pass ec2_role as Role name and click on Create Role button.
Open the ec2_role role and go to the Trust Relationships tab.
Click on the Edit trust relationship tab. Copy-paste the below content and click on the Update Trust Policy button.
{
  “Version”: “2012-10-17”,
  “Statement”: [
    {
      “Effect”: “Allow”,
      “Principal”: {
        “Service”: “ec2.amazonaws.com”
      },
      “Action”: “sts:AssumeRole”
    }
 ]
}

11 Nisan 2022 Pazartesi

GitHub Flow

Giriş
Bu kullanımda sadece iki tane branch tipi var.
1. Master branch
2. Feature branch

Açıklaması şöyle
1. master must always be deployable.
2. all changes made through feature branches (pull-request + merge)
3. rebase to avoid/resolve conflicts; merge in to master
Açıklaması şöyle
If you have participated in open source projects and contributed code, this is definitely not unfamiliar to you. Github has its own unique way, fork, pull request (PR for short), and issue tracking.

First, it will have a remote repository, and then each fork to its own repository. After the development is completed, PR will be sent to the remote repository. If you have any questions You can file an issue, and the person in charge will merge it into the master after approval.

Its core idea is PR and review. The review process is a natural code review process, which can help developers reduce bugs and make the code base more robust. If it is not for the cooperative development of multiple people in the company, I am more inclined to this.

Ne Zaman Kullanılır?
Açıklaması şöyle. Yani ürünün farklı sürümlerini farklı müşterilere vermiyorsam ve ürüne tek bir yerden erişiliyorsa GitHub Flow kullanılabilir. Daha karşık işler için "Git Flow" kullanılabilir
Single version in production simple software

If your code is having only one version in production at all times (i.e. web sites, web services, etc) you may use github-flow. Main reason is that you don't need to complex things for the developer. Once developer finish a feature or finish a bugfix its immediately promoted to production version.
Ben Nasıl Kullandım
Sürüm 5.0, 5.1, 6.0 gibi sürümlere ait yeni branchler açıldı ve bu branchler GitHub Flow gibi kullanıldı. Yani bulunan her hata her bir branch'te ayrı ayrı düzeltildi. Niye Git Flow kullanılmadı ? Bilmiyorum. Çünkü her şey gelip master'a birleşmiyordu

6 Nisan 2022 Çarşamba

Pretty Good Privacy - PGP

Giriş
Açıklaması şöyle
This is an algorithm that was created by Phil Zimmerman in 1991 using the RSA encryption algorithm. PGP encryption is different than other encryption algorithms because it doesn't require a server, certificates, or any other type of pre-shared secrets between senders and recipients to use encryption.

Someone with access to the public key can encrypt data without sharing secret keys with other users before sending them information. This makes it less secure but more flexible when compared to other encryption methods because anyone can send encrypted data without setting up complicated security options ahead of time.