Skip to content

Instantly share code, notes, and snippets.

@eicnix
eicnix / deployment.yaml
Last active July 24, 2018 17:10
sidecarproxy example deployment
# Kubernetes deployment to deploy Sidecar proxy + application in a single pod
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: sidecar-proxy-example
spec:
replicas: 1
selector:
@eicnix
eicnix / deployment.yaml
Last active February 1, 2018 18:07
Protecting Prometheus with OAuth2/OIDC
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: prometheus-deployment
spec:
replicas: 1
template:
metadata:
name: prometheus
spec:
@eicnix
eicnix / removeApplication.sh
Created January 29, 2016 21:19
Removing an application from marathon
#!/bin/sh
curl -X DELETE mymarathonHost:8080/v2/apps/myapp.v1
@eicnix
eicnix / updateBambooUrl.sh
Created January 29, 2016 21:05
Updates the URL inside Bamboo for a running application
#!/bin/sh
curl -X PUT -d '{"id":"myapp.v2", "acl":"path_beg -i /myapp"}' http://localhost:8000/api/services/myapp.v1
@eicnix
eicnix / checkStatus.sh
Created January 29, 2016 20:41
Check the status of the new startedInstances
#!/bin/sh
curl mymarathonHost:8080/v2/apps/myapp.v2 /green | jq '.tasks[].healthCheckResults[] | select (.alive == false)'
@eicnix
eicnix / startInstance.sh
Last active January 29, 2016 20:46
Curl command to start docker container through marathon
#!/bin/sh
curl myMarathonHost:8080/v2/apps -X POST -H 'Content-Type: application/json' -d "{ "container": { \
"type": "DOCKER", \
"docker": { \
"image": "myUser/myapp" \
}, \
"id": "myapp.v2", \
"instances": 1, \
"cpus": 0.5, \
"mem": 512 \
@eicnix
eicnix / MockResponse.scala
Created July 14, 2015 07:54
Mocking complete Response using Scalamock and dispatch
// Example for lukaseichler.de/how-to-test-dispatch-request/
import java.io.InputStream
import java.net.URI
import java.nio.ByteBuffer
import java.util
import com.ning.http.client.cookie.Cookie
import com.ning.http.client.{ FluentCaseInsensitiveStringsMap, Response }
@eicnix
eicnix / RequestSpec.scala
Created July 14, 2015 07:50
Simple response mocking for dispatch using scalamock
// Example for lukaseichler.de/how-to-test-dispatch-request/
import dispatch.{HttpExecutor, _}
import dispatch.Defaults._
val httpMock = mock[HttpExecutor]
(httpMock.apply(_: (Request, AsyncHandler[String]))(_: ExecutionContext))
.expects(*, *)
.returning(Future[String] {
"Hello World"
@eicnix
eicnix / Server.scala
Last active August 29, 2015 14:24
Unfiltered server to test dispatch
// Example for lukaseichler.de/how-to-test-dispatch-request/
val filter = unfiltered.filter.Planify {
case _ => ResponseString(
"Hello World!"
)
}
unfiltered.jetty.Server(8080).plan(filter).run()
@eicnix
eicnix / WorkingExample.scala
Created July 7, 2015 18:28
Parsing nullable types with argonaut
import argonaut._
import Argonaut._
object Main extends App{
val json = "{ \"name\": \"Peter\", \"score\": null}"
case class Player(name: String, score: Option[String])
implicit def PlayerCodecJson: CodecJson[Player] =