Skip to content

Instantly share code, notes, and snippets.

@akoserwal
akoserwal / sample-cr.yaml
Created April 12, 2024 13:51
sample-cr.yaml
apiVersion: com.github.k8soperators.ch3/v1alpha1
kind: GitOps
metadata:
name: gitops-sample
namespace: gitops
spec:
url: ""
@akoserwal
akoserwal / gtiopscrd.yaml
Created April 12, 2024 13:38
gitops-crd
# Generated by Fabric8 CRDGenerator, manual edits might get overwritten!
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: gitops.com.github.k8soperators.ch2
spec:
group: com.github.k8soperators.ch2
names:
kind: GitOps
plural: gitops
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
# One control plane node and three "workers".
#
# While these will not add more real compute capacity and
# have limited isolation, this can be useful for testing
# rolling updates etc.
#
# The API-server and other control plane components will be
# on the control-plane node.
@akoserwal
akoserwal / scannerport.py
Created January 31, 2024 08:45
simple-port-scanner.py
import socket
def scan_ports(target, start_port, end_port):
open_ports = []
for port in range(start_port, end_port + 1):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(1)
result = sock.connect_ex((target, port))
if result == 0:
open_ports.append(port)
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.2
creationTimestamp: null
name: entitlements.authz.authz
spec:
group: authz.authz
kubectl create -f - -o yaml << EOF apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: kafka-cluster-admin-role
rules:
- apiGroups: ["kafka.io"]
resources: ["topics/test/abc"]
verbs: ["create", "delete"]
EOF
@akoserwal
akoserwal / gist:0bdadc056c3ee4f2b9b7364be8a85469
Last active September 8, 2022 11:40
kcp-dev-instruction
$ git clone git@github.com:kcp-dev/kcp.git
$ cd kcp
$ make build-all
```
If $HOME/go/bin is not in your $PATH, you’ll need to add it, or feel free to move $HOME/go/bin/kubectl-kcp, kubectl-ws, kubectl-workspaces to someplace that is in your $PATH
```
$ cd bin
$ ./kcp start
@akoserwal
akoserwal / parsing-key-value-with-jq.sh
Last active July 15, 2022 06:37
parsing-key-value-with-jq
dataseturl=https://gist.githubusercontent.com/akoserwal/4817cccbb53262056405bcc1eef37443/raw/7af7a0a6a60b5e2b8699f0c6e779c236e8f1055d/sample-output.json
map=$(curl $dataseturl | jq -r '.[]')
echo $map
echo $map | jq -r '[.id, .name, .value] | @csv'| tr -d '"' | \
while IFS=, read -r id name value ; do
echo $id:$value
if [[ $name =~ test* ]] ;
then
@akoserwal
akoserwal / sample-output.json
Last active July 15, 2022 06:25
sample-output.json
[
{
"id": "3424234",
"name":"ex2",
"value": "exssasda"
},
{
"id": "342423e4",
"name":"test3",
"value": "tyetryxssasda"
@akoserwal
akoserwal / main.go
Created February 17, 2022 09:35
ocm-server
package main
import (
"bytes"
"encoding/json"
"fmt"
"log"
"net/http"
"os/exec"
"strings"