Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Life is a Poker game not a Chess one

Ahmed ElFakharany abohmeed

💭
Life is a Poker game not a Chess one
View GitHub Profile
@abohmeed
abohmeed / Dockerfile
Created Dec 13, 2020
Dockerfile for sample API written in NodeJS
View Dockerfile
FROM node
ADD index.js package.json /app/
WORKDIR /app
RUN npm install
EXPOSE 3000
ENTRYPOINT ["node","index.js"]
@abohmeed
abohmeed / index.js
Last active Dec 13, 2020
Sample CI/CD pipeline on AWS files
View index.js
var express = require("express");
var app = express();
app.use(express.json())
app.get("/", (req, res, next) => {
res.json({message: "Hello World"});
});
app.listen(3000, () => {
console.log("Server running on port 3000");
});
@abohmeed
abohmeed / fluentbit_configmap.yaml
Last active Oct 10, 2020
fluentbit configmap for rewrite_tag
View fluentbit_configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: fluent-bit-config
labels:
k8s-app: fluent-bit
data:
# Configuration files: server, input, filters and output
# ======================================================
fluent-bit.conf: |
View main.go
package main
import (
"context"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/asn1"
"encoding/base64"
View kubeconfig.yaml
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMwekNDQWJ1Z0F3SUJBZ0lNRmhPQ3Y4MDFIcUQwWmR6Rk1BMEdDU3FHU0liM0RRRUJDd1VBTUJVeEV6QVIKQmdOVkJBTVRDbXQxWW1WeWJtVjBaWE13SGhjTk1qQXdOVEkzTVRNeU56TXpXaGNOTXpBd05USTNNVE15TnpNegpXakFWTVJNd0VRWURWUVFERXdwcmRXSmxjbTVsZEdWek1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBCk1JSUJDZ0tDQVFFQXNuaW5VZldIOU5IU2FBYnd3YnB4VVppYmxMOStEN0ZwNkVSbUlVV2MwVExRTUhHSXdrYTIKcjZLVGh3UnBZZ0xNaTI5YnVTOU4vR1kxQ1JTaGk0T0owMlZKTXF5dGQrMmRsN1dJazcveHN0ckc0YmkwNTQvcApFU0RqNkJOYTZUM1RMUWZYK1Y0NGRHOWdVZG5Kc0plYnQ2Mno2Qnp6ajI3dC81MDNNcmtVQnhtRWtORGtCZHBVCmtPbWdocXgyYSt0dExiTjR1WUswVE4rRjdCQkNuUkVVeHBnNFJDRmc5VG1HaUM5b09vbmE2dWsxTklvMElyeTkKTDNDc3FmUlYrOVBRL3FBT3FrVjNwSnVXSSs1WTJ4Y2JocVJnVWI2QW5QdkpiWkp2Mys2TWt6TkVGNFovWVNYaQp4VGF0VTVGcUJPWDRLNUJ5Y2MvVWRZZG5HKzQ1VjE4cUpRSURBUUFCb3lNd0lUQU9CZ05WSFE4QkFmOEVCQU1DCkFRWXdEd1lEVlIwVEFRSC9CQVV3QXdFQi96QU5CZ2txaGtpRzl3MEJBUXNGQUFPQ0FRRUFldmRXWXZXOGE0bU4KNjZGTHRENXJwR0xsc2VGMFpXSmVVc2dKZTlLTDNXaDBxalNrNEVP
View main.go
kubeConfig, err := clientcmd.LoadFromFile(kubeconfig)
check("The following error occured while loading the KubeConfig file", err)
if _, v := kubeConfig.Clusters[*clusterPtr]; !v {
log.Fatal(fmt.Sprintf("Cluster \"%s\" was not found in the current Kube Config file", *clusterPtr))
}
kc := &KubeConfig{
APIVersion: "v1",
Clusters: Clusters{
0: {
Cluster{
View main.go
csr, err = clientset.CertificatesV1beta1().CertificateSigningRequests().Get(context.TODO(), csr.GetName(), v1.GetOptions{})
clientset.CertificatesV1beta1().CertificateSigningRequests().Delete(context.TODO(), csr.GetName(), v1.DeleteOptions{})
View main.go
check("The following error occured while sending the Certificate Signing Request", err)
csr.Status.Conditions = append(csr.Status.Conditions, certificates.CertificateSigningRequestCondition{
Type: certificates.CertificateApproved,
Reason: "User activation",
Message: "This CSR was approved",
LastUpdateTime: v1.Now(),
})
csr, err = clientset.CertificatesV1beta1().CertificateSigningRequests().UpdateApproval(context.Background(), csr, v1.UpdateOptions{})
check("The following error occured while approving the Certificate Signing Request", err)
View csr.yaml
cat <<EOF | kubectl apply -f -
apiVersion: certificates.k8s.io/v1beta1
kind: CertificateSigningRequest
metadata:
name: tempcsr
spec:
request: $(cat server.csr | base64 | tr -d '\n')
groups:
- system:authenticated
EOF
View main.go
config, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
clientset, err := kubernetes.NewForConfig(config)
check("The following error occured while loading the Kube Config file", err)
csr := &certificates.CertificateSigningRequest{
ObjectMeta: v1.ObjectMeta{
Name: "tempcsr",
},
Spec: certificates.CertificateSigningRequestSpec{
Groups: []string{
"system:authenticated",