title: “aws cli cheatsheet”
date: 2022-02-07T14:05:59
slug: aws-cli-cheatsheet
List Images younger than 2016-04-01
aws ec2 describe-images --query 'Images[?CreationDate>=`2016-04-01`][]'
List Instances
aws ec2 describe-instances --output table
title: “aws cli cheatsheet”
date: 2022-02-07T14:05:59
slug: aws-cli-cheatsheet
List Images younger than 2016-04-01
aws ec2 describe-images --query 'Images[?CreationDate>=`2016-04-01`][]'
List Instances
aws ec2 describe-instances --output table
title: “Use Variable in user_data”
date: 2022-02-04T09:57:30
slug: use-variable-in-user_data
resource "aws\_instance" "web" {
ami = "ami-xxxxxxxxxxxxxxxxx"
instance\_type = "t2.micro"
user\_data = templatefile("${path.module}/init.ps1", {
environment = var.env
hostnames = {"dev":"devhost","test":"testhost","prod":"prodhost"}
})
tags = {
Name = "HelloWorld"
}
}
cat init.sh
#!/bin/bash
echo ${ip} > /tmp/ip
apt update
apt -y upgrade
curl -sfL https://get.k3s.io | INSTALL\_K3S\_EXEC="--tls-san ${ip}" sh -s -
Oder eine Variable definieren um diese öfter zu verwenden:
locals {
web\_user\_data = templatefile("${path.module}/init.ps1", {
environment = var.env
hostnames = {"dev":"devhost","test":"testhost","prod":"prodhost"}
})
}
resource "aws\_instance" "web" {
ami = "ami-xxxxxxxxxxxxxxxxx"
instance\_type = "t2.micro"
user\_data = local.web\_user\_data
tags = {
Name = "HelloWorld"
}
}
title: “Query Elasticsearch Index with Curl”
date: 2021-10-20T12:44:18
slug: query-elasticsearch-index-with-curl
curl -s -k --cert /etc/elasticsearch//secret/admin-cert --key /etc/elasticsearch//secret/admin-key https://localhost:9200/\_cat/indices
title: “OC aggregate container logs”
date: 2021-08-05T06:43:27
slug: oc-aggregate-container-logs
oc logs -f deployment/router-default –all-containers=true
title: “CheetSheet”
date: 2021-07-21T08:08:15
slug: cheetsheet-2
char name[] = "Thomas";
bool active = true;
double workingdays = {1,4,6}
Define Structure with Alias and access it:
typedef struct Point{
int x;
int y;
} Point;
Point one, two;
one.x=5;
one.y=7;
Nested Structure:
typedef struct Point{
int x;
int y;
} Point
typedef struct Location{
int number;
Point p;
} Location
Passing struct to function
#include
#include
struct student
{
int id;
char name[20];
float percentage;
};
void func(struct student \*record);
int main()
{
struct student record;
record.id=1;
strcpy(record.name, "Raju");
record.percentage = 86.5;
func(&record);
return 0;
}
void func(struct student \*record)
{
printf(" Id is: %d
", record->id);
printf(" Name is: %s
", record->name);
printf(" Percentage is: %f
", record->percentage);
}
title: “Filter all Pids”
date: 2021-07-05T22:21:23
slug: filter-all-pids
Program ID to filter. Use 0x2000 to select all PIDs
title: “install k3s”
date: 2021-07-04T09:54:22
slug: install-k3s
Install k3 with custom cerificate
curl -sfL https://get.k3s.io | INSTALL\_K3S\_EXEC="--tls-san 213.95.154.184" sh -s -
Uninstall k3s
/usr/local/bin/k3s-uninstall.sh
Get kube config:
cat /etc/rancher/k3s/k3s.yaml
title: “Timestamp Parser”
date: 2021-06-28T12:57:55
slug: timestamp-parser
An example of such filer from fluent-bit can be seen below:
[PARSER]
Name myapp_parser
Time_Key date
Time_Format %a %b %d %Y %H:%M:%S
Time_Keep On
Format json
Decode_Field json log
title: “Latest OC File”
date: 2021-06-23T08:20:45
slug: latest-oc-file
wget https://mirror.openshift.com/pub/openshift-v4/x86\_64/clients/ocp/latest/openshift-client-linux.tar.gz
title: “force-mcp-ocp-update”
date: 2021-06-20T20:47:54
slug: force-mcp-ocp-update
### Create file called machine-config-daemon-force in /run ###
ssh core@hostname.local sudo touch /run/machine-config-daemon-force
### Edit node annotations ###
oc edit node
### Check Annotations, change like below sample ###
machineconfiguration.openshift.io/currentConfig: rendered-worker-ab4a1e7216bf3da2a5203f09c871b456
machineconfiguration.openshift.io/desiredConfig: rendered-worker-ab4a1e7216bf3da2a5203f09c871b456
machineconfiguration.openshift.io/reason: ""
machineconfiguration.openshift.io/ssh: accessed
machineconfiguration.openshift.io/state: Done