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.

31 Mart 2022 Perşembe

GitHub

1. GitHub'a Link Verme
Eğer bir dosyadaki belirli satırlara link vermek istersek dosya linkinin sonuna  #LBaşlangıçSatırNo-LBitişSatırNo eklenir

Örnek
Şöyle yaparız

2. Fork
Fork işlemi artık sadece "default" dalı getiriyor. Başka bir branch'i de getirmek için kendi repoma giderim. "View all branches" yaparım. "New branch" düğmesine tıklarım ve source olarak esas Github'ı veririm

3. Notifications
Github üzerindeki benden gözden geçirmek istenilen Pull Request'leri görmek için  şöyle yaparız
https://github.com/notifications?query=reason%3Areview-requested

4. Arama
Örnek - dosya ismi
filename:XX ile dosya ismine göre aramak için şöyle yaparız
https://github.com/search?q=org%3AOptivaInc+filename:Cd_fi.xml

5. Dosya İçinde Arama
in:file arama özelliği kullanılıyor

Örnek - kelime
"octocat" kelimesini arar
https://github.com/search?q=octocat+in%3Afile&type=Code
Örnek
Şöyle yaparız
SpringJUnitConfig  lang:Java owner:OrcunColak 

6. Belli Bir Repository Dosyaları İçinde Arama

Örnek
OptivaInc şirketine ait repository'lerdeki dosyalarda "octocat" kelimesini arar
https://github.com/search?q=org%3AOptivaInc+octocat+in%3Afile&type=Code
Şöyle yaparız
https://github.com/search?q=org%3AOptivaInc+INTPcrbdb%3A+in%3Afile&type=Code
Örnek
OptivaInc şirketine ait repository'lerdeki dosyalarda "octocat" kelimesini  uzantısı gradle olan dosyalarda arar
https://github.com/search?p=1&q=org%3AOptivaInc+octocat+in%3Afile+extension%3Agradle&type=Code
Issue
Created By ile Arama
Şöyle yaparız
https://github.com/hazelcast/hazelcast/issues/created_by/ocolak
Filtre bölümüne şunu yazabiliriz
is:open is:issue archived:false author:ocolak
İki repodaki label'lara bakmak için şöyle yaparız
is:issue repo:hazelcast/hazelcast repo:hazelcast/hazelcast-enterprise is:open label:"Type: Test-Failure" sort:created-desc 
GitHub Pull Request
Pull Request için açılan gözden geçirmeye yorum varsa, soruyu soran kişi Resolve Conversation işlemini yapar.

GitHub Review
1. Koda yorumları gir. Yorumlar Add single comment veya Start a review olarak girilebilir. Açıklaması şöyle
There are two options:
1. Add a single comment
2. Start a review

If you click on add single comment, the comment will be made immediately.

If you click on start a review, you’ll have the chance to write more comments before sending them at once. To end the review, you need to click on the Review changes button and select submit review.
 Start a review olarak girdiysek her girilen yorum Pending olarak gösterilir. Gözden geçirme bitince Review changes düğmesine tıklanır ve Request changes düğmesine tıklanır

Git Hook
Açıklaması şöyle
Git hooks are scripts that run automatically every time a particular event occurs in a Git repository. They let you customize Git’s internal behavior and trigger customizable actions at key points in the development life cycle.
maven için git-build-hook plugin kullanılabilir

Web Hook
Açıklaması şöyle
Go to the settings of your GitHub repository and go to Webhooks. Add a new webhook, add the previously generated public URL + “/github-webhook/” to the Payload URL and change the content type to application/json. Select Just the push event to trigger the webhook, and finally click Add webhook.
Şeklen şöyle




24 Mart 2022 Perşembe

Jaro-Winkler Similarity

Jaro Similarity
Açıklaması şöyle
Created by Matthew A. Jaro in 1989, the Jaro Similarity metric compares two strings and gives us a score that represents how similar they are.

The result is a number between 0 and 1, where 0 means the strings are completely different and 1 means they match exactly.

The first step to calculating the Jaro similarity is to count the characters that match between the two strings.

But, to be considered a 'match', the characters do not need to be in the same place in both strings - they just need to be near to each other.

This accounts for the common typing mistake where you accidentally enter some characters in the wrong order.
Jaro-Winkler Similarity
Açıklaması şöyle
This modification of Jaro Similarity was proposed in 1990 by William E. Winkler.

The 'Jaro-Winkler' metric takes the Jaro Similarity above, and increases the score if the characters at the start of both strings are the same.

In other words, Jaro-Winkler favours two strings that have the same beginning.

21 Mart 2022 Pazartesi

DevOps Maturity Assessment Models

Giriş
DevOps Olgunluk Modelleri şöyle
Phase 0: Disorganized 
No DevOps process is in place, or the management has no idea how beneficial automation and integration are. Development and operations teams work independently, and the software is tested manually. Desired changes take a long time to go into production.

Phase 1: Structured
Some processes are put in place, but they are very loosely defined, and there is little or no automation. Companies in this phase experiment with DevOps practices on small teams before scaling it to larger IT projects.

Phase 2: Managed 
A more mature process is defined, including automation for some essential tasks. Agile practices are widely adopted in the development and operations sectors.

Phase 3: Measured
Teams have a strong understanding of DevOps practices, and automation replaces most manual processes. Agile performance metrics are defined and incorporated into the process. Performance information is gathered via automation and fed back into the process to drive improvements.

Phase 4: Optimized
The focus in this phase is continuous improvement, and DevOps processes are entrenched across teams. You are running experiments across different parts of your architecture and using insights gained from your data to make changes and improve performance.