Skip to content

Instantly share code, notes, and snippets.

View denzhel's full-sized avatar
🇺🇦

Dennis Zheleznyak denzhel

🇺🇦
View GitHub Profile
@denzhel
denzhel / aws_hosted_zone_resolve.md
Created April 25, 2022 19:26
aws allow vpc to resolve hosted zone

To allow VPCs to resolve AWS Route53 hosted zones, you need to run the following for each zone and VPC:

aws route53 create-vpc-association-authorization --hosted-zone-id <HostedZoneID> --vpc VPCRegion=<VPCregion>,VPCId=<VPCID>
aws route53 associate-vpc-with-hosted-zone --hosted-zone-id <HostedZoneID> --vpc VPCRegion=<VPCregion>,VPCId=<VPCID>
@denzhel
denzhel / jenkins_github_matrix.md
Created April 24, 2022 20:32
jenkins github matrix

If you're trying to trigger a Jenkins job using the CLI and get the following errors:

curl -H "Authorization: token abcdefg" .....

    Authentication required
    401 Error

You should chceck if you are using a Matrix Security, if so you should authenticate using a user:

curl --user : ....
@denzhel
denzhel / jenkins_decrypt_secrets.md
Created April 24, 2022 20:28
jenkins decrypt all secrets

To decrypt all Jenkins Secrets, you can use the following code inside Manage Jenkins -> Script Console:

def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
    com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class,
    Jenkins.instance,
    null,
    null
);
for (c in creds) {
 println( ( c.properties.privateKeySource ? "ID: " + c.id + ", UserName: " + c.username + ", Private Key: " + c.getPrivateKey() : ""))
@denzhel
denzhel / kubectl_events_latest.md
Created April 19, 2022 13:05
kubectl get ordered events

To get the latest ordered events of Kubernetes, run the following:

kubectl get events --sort-by=.metadata.creationTimestamp
@denzhel
denzhel / ansible_filter_element_from_array.md
Created April 14, 2022 18:30
ansible filter element from array

If you want to filter out an element from an array, use the following filter:

| reject('search', '-11')

For example:

mongo_servers: "{{ groups['tag_role_mongo3'] | intersect(groups[env_tag]) | map('extract', hostvars, ['tags', 'fqdn']) | reject('search', '-11') }}"
@denzhel
denzhel / es_snapshot.md
Last active April 14, 2022 18:27
elasticsearch snapshot commands

Use the following command to configure a S3 repository to restore snapshot from:

curl -XPUT -H 'Content-Type: application/json' 'http://localhost:9200/_snapshot/s3-backup?pretty' -d'
{
 "type" : "s3",
 "settings" : {
 "bucket" : "<bucketName>",
 "region": "us-west-1",
 "base_path" : "<someDirectory>" <=== This can be omitted if snapshots are located at root
 }
@denzhel
denzhel / es_speed_up_recovery.md
Created April 14, 2022 18:23
elasticsearch speed up recovery

To speed up recovery from a down time or restore from snapshot, use the following settings:

curl -XPUT -H 'Content-Type: application/json' 'http://localhost:9200/_cluster/settings' -d'
{
  "persistent": {
    "indices.recovery.max_bytes_per_sec": "1000mb",
    "cluster.routing.allocation.node_concurrent_recoveries": "10"
  }
}'
@denzhel
denzhel / aws_iam_allow_access_s3.md
Created April 14, 2022 18:22
AWS IAM allow access for S3 bucket

To allow a ceratin resource to access a S3 bucket, use the following IAM policy:

        {
            "Effect": "Allow",
            "Action": [
                "s3:*"
            ],
            "Resource": [
                "arn:aws:s3:::<bucketName>/*",
                "arn:aws:s3:::<bucketName>"
@denzhel
denzhel / k8s_scale_all_to_0.md
Created April 14, 2022 18:18
kubernetes scale all deployments to 0

To scale all deployments in a namespace to 0, use the following:

kubectl scale deployment --all --replicas=0
@denzhel
denzhel / bash_show_all_sizes.md
Created April 14, 2022 18:17
bash show size of ALL files and directories

If you want to print the size of all files and folders in a current directory, use the following:

sudo du -sch .[!.]* * | sort -h