Skip to content

Instantly share code, notes, and snippets.

@robzienert
Created September 28, 2017 20:49
Show Gist options
  • Save robzienert/292eb416c8b3b9cc27a4cee8474d659c to your computer and use it in GitHub Desktop.
Save robzienert/292eb416c8b3b9cc27a4cee8474d659c to your computer and use it in GitHub Desktop.
local s = import "v1.jsonnetlib";
local spinnakerTeam = import "spinnaker://spinnakerTeam.jsonnetlib";
local spin = s.intent.SpinnakerFileType;
local application = s.intent.ApplicationType;
local pipeline = s.intent.PipelineType;
local notification = s.intent.NotificationType;
local cluster = s.intent.ClusterType;
local promotion = s.intent.PromotionWorkflowType;
local securityGroup = s.intent.aws.AwsSecurityGroupType;
local loadBalancer = s.intent.aws.AwsClassicLoadBalancerType;
local redisGroup = "a";
local clusters = [
{
detail: redisGroup,
},
{
detail: redisGroup + "-api",
} + cluster.mixins.aws.simpleCapacity(6),
{
detail: redisGroup + "-api-readonly",
},
{
detail: redisGroup + "-api-readonly-deck",
},
{
detail: redisGroup + "-api-readonly-orca"
},
{
detail: redisGroup + "-api-readonly-orca-1"
},
{
detail: redisGroup + "-api-readonly-orca-2"
},
{
detail: redisGroup + "-api-readonly-orca-3"
},
{
detail: redisGroup + "-api-readonly-orca-4"
},
];
local loadBalancers = ['', 'readonly', 'readonly-deck', 'readonly-orca', 'readonly-orca-1', 'readonly-orca-2', 'readonly-orca-3', 'readonly-orca-4'];
local app = application.new("clouddriver", "spinnaker@example.com", "cloud read and write operations") +
application.mixins.group("spinnaker") +
application.mixins.pagerDuty("Spinnaker") +
application.mixins.cloudProviders("aws") +
application.mixins.notifications(
notification.slack("#example", [
notification.mixins.complete(),
notification.mixins.failed()
])
) +
application.mixins.features.disabled("timeline") +
application.mixins.trafficGuards({ account: "mgmt", region: "*", stack: "*", detail: "*" }) +
application.mixins.securityGroups([
securityGroup.new("clouddriver", "Security group for clouddriver") +
securityGroup.mixins.rules(securityGroup.mixins.ingress("clouddriver", "tcp", 6379, 6379)),
// remote imported: The spinnaker-internal-service security group is shared
// by most services and defined elsewhere.
spinnakerTeam.mixins.securityGroup.internalService()
]) +
application.mixins.loadBalancers([
loadBalancer.new(lb) +
loadBalancer.mixins.internal() +
loadBalancer.mixins.securityGroups(spinnakerTeam.mixins.securityGroup.internalServiceElb()) +
loadBalancer.mixins.listeners([
loadBalancer.mixins.listener("http", 80, "http", 7001),
loadBalancer.mixins.listener("tcp", 443, "tcp", 7002)
]) +
loadBalancer.mixins.healthCheck("http", 7001, "/health") + {
timeout: 5,
interval: 10,
healthyThreshold: 5,
unhealthyThreshold: 5,
}
for lbDetail in loadBalancers
]) +
// FUTURE FEATURE:
// Defining clusters & promotionWorkflow is an alternative to explicit pipeline
// definitions. When these two are defined, Spinnaker is able to infer basic
// pipelines that need to be created to release software. If the inferred
// pipelines do not fit, they can be individually substituted case-by-case.
application.mixins.clusters([
// Defines a root-level (incomplete) cluster definition that is made concrete
// by the clusters variable. The stdlib would have default values that raise
// errors if they're not overridden.
cluster.new() +
// TODO rz - I think placement could be inferred, but I don't know where
// this information would be provided otherwise or how to intelligently
// figure it out yet.
// cluster.mixins.aws.placement("mgmt", ["us-west-2"], "internal (vpc0)") +
cluster.mixins.aws.simpleCapacity(4) +
cluster.mixins.strategy.redblack(2, false) +
cluster.mixins.securityGroups([
"clouddriver",
"spinnaker-internal-service"
]) +
cluster.mixins.aws.scalingProcessesExcept("AZRebalance") + {
detail: c.detail,
instanceType: "c3.2xlarge",
keyName: "myKeyPairExample",
iamInstanceProfile: "clouddriverInstanceProfile"
}
for c in clusters
]) +
application.mixins.promotionWorkflow(
// Defines an ordered promotion workflow for an application to progress
// through. Both accounts & stacks can be arrays or single strings. If we
// wanted to customize the promotion workflow (e.g. "don't use the default,
// inferred pipeline topology, use this specific pipeline instead") would
// probably be defined here as well.
promotion.new() +
promotion.mixins.phase(0, "mgmttest", "test", "us-west-2") +
promotion.mixins.phase(1, "mgmt", ["loadtemp", "main"], ["us-west-2", "us-east-1"])
);
spin.new(app)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment