Skip to content

Instantly share code, notes, and snippets.

View ilyesAj's full-sized avatar

ilyes Ajroud ilyesAj

View GitHub Profile
@ilyesAj
ilyesAj / busybox.yaml
Last active January 25, 2023 12:32
copy file into file storage StatS using CaaS
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: pv-mounter
spec:
selector:
matchLabels:
app: pv-mounter
template:
@ilyesAj
ilyesAj / awscli-cp-job-buffered.yaml
Last active August 24, 2022 13:07
a buffered version of s3 copy using kubernetes
apiVersion: v1
kind: Namespace
metadata:
name: s3-copy
---
apiVersion: batch/v1
kind: Job
metadata:
name: s3-copy-bucket-a
namespace: s3-copy
@ilyesAj
ilyesAj / awscli-cp-job.yaml
Created August 22, 2022 14:31
aws cp job kubernetes
apiVersion: v1
kind: Namespace
metadata:
name: s3-copy
---
apiVersion: batch/v1
kind: Job
metadata:
name: s3-bucket-a-sync
namespace: s3-copy
#!/bin/bash
# this script will allow you to append policy within a bucket
# you need to install jq awscli to use this script
[ $# != 1 ] && { echo "Usage: $0 \"bucket_name\""; exit 1; }
bucket="$1"
json_to_add="{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::ACCOUNT-B:user/s3-cross-account\"},\"Action\":[\"s3:ListBucket\",\"s3:GetObject\"],\"Resource\":[\"arn:aws:s3:::${bucket}\",\"arn:aws:s3:::${bucket}/*\"]}"
# get bucket policy
aws s3api get-bucket-policy --bucket ${bucket} --query Policy --output text > policy-${bucket}.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::Account-B:user/s3-cross-account"
},
"Action": [
"s3:GetObject",
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::ACCOUNT_B:user/s3-cross-account"
},
"Action": [
"s3:ListBucket",
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ReadBucketA",
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetObject"
],
@ilyesAj
ilyesAj / gitlab-ci.yaml
Last active June 12, 2022 21:58
ci to to test runner autoscale
job:
parallel: 50
image: alpine:latest
script:
- echo "hello my friend"
- sleep 60
tags:
- k8s,ops
...
hpa:
minReplicas: 1
maxReplicas: 10
metrics:
- type: External
external:
metricName: gitlab_runner_jobs_builds_concurrent_saturation
targetAverageValue: 0.4
$ kubectl get --raw "/apis/external.metrics.k8s.io/v1beta1" | jq .
{
"kind": "APIResourceList",
"apiVersion": "v1",
"groupVersion": "external.metrics.k8s.io/v1beta1",
"resources": [
{
"name": "gitlab_runner_jobs_builds_concurrent_saturation",
"singularName": "",
"namespaced": true,