Skip to content

Instantly share code, notes, and snippets.

View aespinosa's full-sized avatar

Allan Espinosa aespinosa

View GitHub Profile
V1CustomResourceDefinition crd = Yaml.loadAs(new File("mycrd.yaml"), V1CustomResourceDefinition.class);
JSON crdSerializer = new JSON();
ObjectMapper oasSerializer = Json.mapper();
OpenAPI openapi = new OpenAPI().components(new Components());
Components components = openapi.getComponents();
for (V1CustomResourceDefinitionVersion version : crd.getSpec().getVersions()) {
V1JSONSchemaProps crdSchema = version.getSchema().getOpenAPIV3Schema();
JsonSchema oasSchema = oasSerializer.readValue(crdSerializer.serialize(crdSchema), JsonSchema.class);
oasSchema.extensions(new HashMap<>())
.addExtension("x-kubernetes-group-version-kind", List.of(Map.of("kind", crd.getSpec().getNames().getKind(), "group", crd.getSpec().getGroup(), "version", version.getName())));
@aespinosa
aespinosa / KubernetesTest.java
Created February 12, 2021 03:04
Integration testing with the Kubernetes Java Client
// Start a Kubernetes Cluster. For building a controller we don't really
// need to have worker nodes. The control plane should be plenty.
// k3s server gives much more than that the controller-runtime test suite
// provides (no controller-manager and scheduler)
Path tempDir = Files.createTempDirectory("kube-cluster");
File kubeConfig = new File(tempDir.toFile(), "k3s.yaml");
Process k3sServer = new ProcessBuilder("k3s", "server", "--disable-agent",
"--bind-address", "127.0.0.1",
"--data-dir", tempDir.toString(),
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: genius
namespace: bach-system
annotations:
kubernetes.io/ingress.class: traefik
traefik.ingress.kubernetes.io/browser-xss-filter: "true"
traefik.ingress.kubernetes.io/content-type-nosniff: "true"
# Bind to port 80 and convince users to upgrade to TLS (forcefully)
server {
listen 80;
server_name genius.dev.hadoop.bloomberg.com;
rewrite ^ https://genius.dev.hadoop.bloomberg.com$request_uri? permanent;
}
# The actual TLS port binding
server {
@aespinosa
aespinosa / maven.log
Last active August 14, 2019 14:49
Shading io.kubernetes:client-java
ERROR] Failed to execute goal on project shade-kubernetes: Could not resolve dependencies for project io.espinosa:shade-kubernetes:jar:1.0-SNAPSHOT: Could not find artifact com.sun:tools:jar:1.7 at specified path /usr/lib/jvm/java-8-jdk/jre/../lib/tools.jar -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project shade-kubernetes: Could not resolve dependencies for project io.espinosa:shade-kubernetes:jar:1.0-SNAPSHOT: Could not find artifact com.sun:tools:jar:1.7 at specified path /usr/lib/jvm/java-8-jdk/jre/../lib/tools.jar
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies (LifecycleDependencyResolver.java:269)
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies (LifecycleDependencyResolver.java:147)
at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved (MojoExecutor.java:248)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecu
services.nexus.enable = true;
services.nginx.enable = true;
services.nexus.package = unstablePackages.nexus;
services.nginx.virtualHosts."nexus.nixos.test" = {
locations."/" = {
proxyPass = "http://localhost:8081";
};
extraConfig = ''
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
@aespinosa
aespinosa / hbase.txt
Created June 11, 2018 16:41
List of Region Metrics in HBase
metric_storeFileCount
metric_memStoreSize
metric_maxStoreFileAge
metric_minStoreFileAge
metric_avgStoreFileAge
metric_numReferenceFiles
metric_storeFileSize
metric_compactionsCompletedCount
metric_numBytesCompactedCount
metric_numFilesCompactedCount
@aespinosa
aespinosa / bosh.log
Last active April 11, 2018 23:51
bosh stop -d cf --skip-drain
bosh stop --skip-drain -d cf
Using environment 'https://10.0.0.6:25555' as client 'admin'
Using deployment 'cf'
Continue? [yN]: y
Task 243
Task 243 | 23:44:26 | Preparing deployment: Preparing deployment (00:00:05)
// @description anonymizer
document.body.innerHTML.replace('[email protected]', 'dockerhp@email');
@aespinosa
aespinosa / pr-817.patch
Created August 15, 2017 17:37
diff between bloomberg/chef-bach#817 and aespinosa/chef-bach/proper-hive-hash
diff --git a/cookbooks/bcpc-hadoop/recipes/hive_config.rb b/cookbooks/bcpc-hadoop/recipes/hive_config.rb
index d5b3dab..98f9375 100644
--- a/cookbooks/bcpc-hadoop/recipes/hive_config.rb
+++ b/cookbooks/bcpc-hadoop/recipes/hive_config.rb
@@ -31,12 +31,13 @@ stats_password = make_config('mysql-hive-table-stats-password', secure_password)
end
hive_site_vars = {
- is_hive_serverzzzz: node.run_list.expand(node.chef_environment).recipes.include?('bcpc-hadoop::hive_hcatalog'),
+ is_hive_server: node.run_list.expand(node.chef_environment).recipes.include?('bcpc-hadoop::hive_hcatalog'),