Skip to content

Instantly share code, notes, and snippets.

View guaxinim's full-sized avatar

Elvis Rocha guaxinim

  • Red Hat
  • Brasilia - Brazil
View GitHub Profile
@guaxinim
guaxinim / README-fail2ban-keycloak.md
Created May 14, 2022 01:58 — forked from drmalex07/README-fail2ban-keycloak.md
Use fail2ban to block brute-force attacks to keycloak server. #keycloak #fail2ban #brute-force-attack

Add regular-expression filter under /etc/fail2ban/filter.d/keycloak.conf:

[INCLUDES]

before = common.conf

[Definition]

_threadName = [a-z][-_0-9a-z]*(\s[a-z][-_0-9a-z]*)*
_userId = (null|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})
@guaxinim
guaxinim / gist:8af596fdaf25de17e63c3f96409656cd
Last active June 25, 2019 19:24
Openshift / Kubernetes
Listar logs e recursos de um DC, Pod
oc adm top pods --all-namespaces
oc get dc --all-namespaces -o jsonpath='{range .items[*]}{"NAMESPACE: "}{@.metadata.namespace}{" DeploymentConfig: "}{@.spec.selector.deploymentconfig}{" Request CPU: "}{@.spec.template.spec.containers[].resources.requests.cpu}{" Request MEMORIA: "}{@.spec.template.spec.containers[].resources.requests.memory}{" Limit CPU: "}{@.spec.template.spec.containers[].resources.limits.cpu}{" Limit MEMORIA: "}{@.spec.template.spec.containers[].resources.limits.memory}{"\n"}{end}'
Comandos uteis
oc api-resources
oc explain <object>
oc explain dc.spec
@guaxinim
guaxinim / S2i from a private repo
Last active July 27, 2022 23:22
Openshift S2i from a private repo
ssh-keygen -C "openshift-source-builder/repo@github" -f repo-at-github -N ''
oc secrets new-sshauth elvis-secret --ssh-privatekey=repo-at-github
secrets add serviceaccount/builder secrets/elvis-secret
oc set build-secret --source bc/serpro-ws elvis-secret
oc new-build fis-java-openshift~ssh://[email protected]:2222/erocha/serpro-ws.git --build-secret elvis-secret
oc new-app serpro-ws
1. Create a configmap (or a secret)
key: pg.env
value:
DATASOURCES=TESTDB_POSTGRESQL
TESTDB_POSTGRESQL_PASSWORD=testpwd
TESTDB_POSTGRESQL_DATABASE=testdb
TESTDB_POSTGRESQL_USERNAME=testuser
Interno (da maquina master por exemplo)
docker pull busybox
docker tag docker.io/busybox 172.30.88.167:5000/openshift/busybox
docker login -u admin -e [email protected] -p psmVILEDl2wRWh3kr_J-Ef1xBBTaeNTmnpid66vjNyQ 172.30.88.167:5000
docker push 172.30.88.167:5000/openshift/busybox
Externo
for i in $(oc get projects | grep Terminating| awk '{print $1}'); do echo $i; oc get serviceinstance -n $i -o yaml | sed "/kubernetes-incubator/d"| oc apply -f - ; done
for i in $(oc get projects | grep Terminating| awk '{print $1}'); do echo $i; oc get servicebinding -n $i -o yaml | sed "/kubernetes-incubator/d"| oc apply -f - ; done
@guaxinim
guaxinim / java_trust_ca
Created December 3, 2017 00:11
Create a java app in a container that trusts in a specific CA
1) Create a Dockerfile build with FROM pointing at one of app base images (call it `example-com-eap7`)
2) ADD or COPY example.com's CA (for EAP, this looks something like `ADD configs/certs/cacerts_JDK8 /etc/pki/ca-trust/extracted/java/cacerts`)
3) Create new apps based on `example-com-eap7` (`oc new-app example-com-eap7~...`)
The jist is, if you can add the pertinent files to `/etc/pki/ca-trust/` then the apps & pods should be good.
@guaxinim
guaxinim / Macro Excel
Created September 6, 2016 20:10
Macro de preenchimento automático no excel
Private Sub CommandButton1_Click()
Dim quantidade As Integer
Dim asque As Integer
asque = 65
Dim cela As Integer
cela = ActiveCell.Row
quantidade = cela + Cells(1, 9) - 1
Dim coluna As Integer
Sub Macro_PreencheColunaA()
Dim quantidade As Integer
Dim asque As Integer
asque = 65
Dim cela As Integer
cela = 14
quantidade = cela + 9
Dim coluna As Integer
coluna = 4
Dim valorCelula As String
@guaxinim
guaxinim / eap6_remote_jmx
Created May 14, 2013 17:17
Acesso ao JBoss EAP 6 remoto via VisualVM
JBoss implements a JSR 160 compliant JMXConnector instead of an RMI interface to establish a connection to a JMX MBeanServer form a remote client.
There is no need for any additional JVM options. The JMXConnector uses under the hood JBoss Remoting for the transport and by default the native management endpoint of the AS7 if the server is running in the standalone mode.
To access the management endpoints a management user in the realm ManagementRealm is required
add the user: ./add-user.sh
Add the folowing libs on classpath:
org/jboss/remoting3/remoting-jmx
org/jboss/remoting3