Skip to content

Commit

Permalink
[helm] add option to create real network address for pfn
Browse files Browse the repository at this point in the history
Closes: #232
  • Loading branch information
sherry-x authored and aptos-bot committed Mar 17, 2022
1 parent b1601d2 commit e1a508c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
37 changes: 37 additions & 0 deletions terraform/fullnode/fullnode/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
{{- $fullName := include "pfn.fullname" . -}}
{{- $labels := include "pfn.labels" . -}}
{{- $domain := .Values.service.domain -}}
{{- $loadBalancerSourceRanges := .Values.service.fullnode.loadBalancerSourceRanges -}}

{{- if .Values.service.fullnode.enableOnchainDiscovery }}
# create internet facing network address for fullnode
# to allow onchain discovery
{{- range $i, $e := .Values.service.fullnode.numFullnodes | int | until }}
apiVersion: v1
kind: Service
metadata:
name: {{ printf "%s-fullnode-%d" $fullName $i | quote }}
labels:
{{- $labels | nindent 4 }}
annotations:
service.beta.kubernetes.io/aws-load-balancer-type: nlb
{{- if $domain }}
external-dns.alpha.kubernetes.io/hostname: {{ printf "pfn%d.%s" $i $domain | quote }}
{{- end }}
alb.ingress.kubernetes.io/healthcheck-path: /-/healthy
spec:
selector:
app.kubernetes.io/instance: {{ printf "pfn%d" $i | quote }}
app.kubernetes.io/part-of: aptos-fullnode
app.kubernetes.io/name: fullnode
ports:
- name: aptosnet
port: 6182
type: LoadBalancer
externalTrafficPolicy: Local
loadBalancerSourceRanges:
{{- toYaml $loadBalancerSourceRanges | nindent 4 }}
---
{{- end }}
{{- end }}

{{- if .Values.service.fullnode.exposeApi }}
apiVersion: v1
kind: Service
Expand Down
1 change: 1 addition & 0 deletions terraform/fullnode/fullnode/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ service:
fullnode:
numFullnodes:
exposeApi: true
enableOnchainDiscovery: false
loadBalancerSourceRanges:
domain:
aws_tags:
Expand Down
5 changes: 3 additions & 2 deletions terraform/fullnode/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ resource "helm_release" "fullnode" {
wait = false

values = [
jsonencode(var.fullnode_helm_values),
jsonencode({
chain = {
era = var.era
Expand All @@ -132,6 +131,8 @@ resource "helm_release" "fullnode" {
class = "gp2"
}
}),
jsonencode(var.fullnode_helm_values),
jsonencode(var.fullnode_helm_values_list == {} ? {} : var.fullnode_helm_values_list[count.index]),
]

set {
Expand All @@ -149,7 +150,6 @@ resource "helm_release" "pfn-logger" {
wait = false

values = [
jsonencode(var.pfn_logger_helm_values),
jsonencode({
logger = {
name = "pfn"
Expand All @@ -158,6 +158,7 @@ resource "helm_release" "pfn-logger" {
name = "aptos-${terraform.workspace}"
}
}),
jsonencode(var.pfn_logger_helm_values),
]

set {
Expand Down
6 changes: 6 additions & 0 deletions terraform/fullnode/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ variable "fullnode_helm_values" {
default = {}
}

variable "fullnode_helm_values_list" {
description = "List of values to pass to public fullnode, for setting different value per node. length(fullnode_helm_values_list) must equal var.num_fullnodes"
type = any
default = {}
}

variable "zone_id" {
description = "Route53 Zone ID to create records in"
default = ""
Expand Down

0 comments on commit e1a508c

Please sign in to comment.