-
Notifications
You must be signed in to change notification settings - Fork 502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
services/horizon/docker/ledgerexporter: deploy ledgerexporter image as service #4490
Changes from all commits
846c6fc
cdd60d5
2cc3a3d
b1589f0
466b366
433ed4f
ffd3990
873e79f
b56e089
2c8589c
f0321b6
6c95fe8
452b20c
eebaedd
a02547b
415950e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
PEER_PORT=11725 | ||
DATABASE = "sqlite3:///cc/stellar.db" | ||
|
||
UNSAFE_QUORUM=true | ||
FAILURE_SAFETY=1 | ||
|
||
[[HOME_DOMAINS]] | ||
HOME_DOMAIN="testnet.stellar.org" | ||
QUALITY="HIGH" | ||
|
||
[[VALIDATORS]] | ||
NAME="sdf_testnet_1" | ||
HOME_DOMAIN="testnet.stellar.org" | ||
PUBLIC_KEY="GDKXE2OZMJIPOSLNA6N6F2BVCI3O777I2OOC4BV7VOYUEHYX7RTRYA7Y" | ||
ADDRESS="core-testnet1.stellar.org" | ||
HISTORY="curl -sf http://history.stellar.org/prd/core-testnet/core_testnet_001/{0} -o {1}" | ||
|
||
[[VALIDATORS]] | ||
NAME="sdf_testnet_2" | ||
HOME_DOMAIN="testnet.stellar.org" | ||
PUBLIC_KEY="GCUCJTIYXSOXKBSNFGNFWW5MUQ54HKRPGJUTQFJ5RQXZXNOLNXYDHRAP" | ||
ADDRESS="core-testnet2.stellar.org" | ||
HISTORY="curl -sf http://history.stellar.org/prd/core-testnet/core_testnet_002/{0} -o {1}" | ||
|
||
[[VALIDATORS]] | ||
NAME="sdf_testnet_3" | ||
HOME_DOMAIN="testnet.stellar.org" | ||
PUBLIC_KEY="GC2V2EFSXN6SQTWVYA5EPJPBWWIMSD2XQNKUOHGEKB535AQE2I6IXV2Z" | ||
ADDRESS="core-testnet3.stellar.org" | ||
HISTORY="curl -sf http://history.stellar.org/prd/core-testnet/core_testnet_003/{0} -o {1}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# this file contains the ledgerexporter deployment and it's config artifacts. | ||
# | ||
# when applying the manifest on a cluster, make sure to include namespace destination, | ||
# as the manifest does not specify namespace, otherwise it'll go in your current kubectl context. | ||
# | ||
# make sure to set the secrets values, substitue <base64 encoded value here> placeholders. | ||
# | ||
# $ kubectl apply -f ledgerexporter.yml -n horizon-dev | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
annotations: | ||
fluxcd.io/ignore: "true" | ||
labels: | ||
app: ledgerexporter | ||
name: ledgerexporter-pubnet-env | ||
data: | ||
# when using core 'on disk', the earliest ledger to get streamed out after catchup to 2, is 3 | ||
# whereas on in-memory it streas out 2, adjusted here, otherwise horizon ingest will abort | ||
# and stop process with error that ledger 3 is not <= expected ledger of 2. | ||
START: "0" | ||
END: "0" | ||
|
||
# can only have CONTINUE or START set, not both. | ||
CONTINUE: "true" | ||
WRITE_LATEST_PATH: "true" | ||
sreuland marked this conversation as resolved.
Show resolved
Hide resolved
|
||
CAPTIVE_CORE_USE_DB: "true" | ||
|
||
# configure the network to export | ||
HISTORY_ARCHIVE_URLS: "https://history.stellar.org/prd/core-live/core_live_001,https://history.stellar.org/prd/core-live/core_live_002,https://history.stellar.org/prd/core-live/core_live_003" | ||
NETWORK_PASSPHRASE: "Public Global Stellar Network ; September 2015" | ||
# can refer to canned cfg's for pubnet and testnet which are included on the image | ||
# `/captive-core-pubnet.cfg` or `/captive-core-testnet.cfg`. | ||
# If exporting a standalone network, then mount a volume to the pod container with your standalone core's .cfg, | ||
# and set full path to that volume here | ||
CAPTIVE_CORE_CONFIG: "/captive-core-pubnet.cfg" | ||
|
||
# example of testnet network config. | ||
# HISTORY_ARCHIVE_URLS: "https://history.stellar.org/prd/core-testnet/core_testnet_001,https://history.stellar.org/prd/core-testnet/core_testnet_002" | ||
# NETWORK_PASSPHRASE: "Test SDF Network ; September 2015" | ||
# CAPTIVE_CORE_CONFIG: "/captive-core-testnet.cfg" | ||
|
||
# provide the url for the external s3 bucket to be populated | ||
# update the ledgerexporter-pubnet-secret to have correct aws key/secret for access to the bucket | ||
ARCHIVE_TARGET: "s3://horizon-ledgermeta-prodnet-test" | ||
--- | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
labels: | ||
app: ledgerexporter | ||
name: ledgerexporter-pubnet-secret | ||
type: Opaque | ||
data: | ||
AWS_REGION: <base64 encoded value here> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AWS credentials get loaded into the cluster as secrets, which deployment pulls into ledgerexporter container as env variables. |
||
AWS_ACCESS_KEY_ID: <base64 encoded value here> | ||
AWS_SECRET_ACCESS_KEY: <base64 encoded value here> | ||
--- | ||
# running captive core with on-disk mode limits RAM to around 2G usage, but | ||
# requires some dedicated disk storage space that has at least 3k IOPS for read/write. | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: ledgerexporter-pubnet-core-storage | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 500Gi | ||
storageClassName: default | ||
volumeMode: Filesystem | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
annotations: | ||
fluxcd.io/ignore: "true" | ||
deployment.kubernetes.io/revision: "3" | ||
labels: | ||
app: ledgerexporter-pubnet | ||
name: ledgerexporter-pubnet-deployment | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: ledgerexporter-pubnet | ||
replicas: 1 | ||
template: | ||
metadata: | ||
annotations: | ||
fluxcd.io/ignore: "true" | ||
# if we expect to add metrics at some point to ledgerexporter | ||
# this just needs to be set to true | ||
prometheus.io/port: "6060" | ||
prometheus.io/scrape: "false" | ||
labels: | ||
app: ledgerexporter-pubnet | ||
spec: | ||
containers: | ||
- envFrom: | ||
- secretRef: | ||
name: ledgerexporter-pubnet-secret | ||
- configMapRef: | ||
name: ledgerexporter-pubnet-env | ||
image: stellar/horizon-ledgerexporter:latest | ||
imagePullPolicy: Always | ||
name: ledgerexporter-pubnet | ||
resources: | ||
limits: | ||
cpu: 3 | ||
memory: 8Gi | ||
requests: | ||
cpu: 500m | ||
memory: 2Gi | ||
volumeMounts: | ||
- mountPath: /cc | ||
name: core-storage | ||
dnsPolicy: ClusterFirst | ||
volumes: | ||
- name: core-storage | ||
persistentVolumeClaim: | ||
claimName: ledgerexporter-pubnet-core-storage | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,15 +12,17 @@ import ( | |
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/s3" | ||
"github.com/aws/aws-sdk-go/service/s3/s3iface" | ||
"github.com/stellar/go/support/errors" | ||
) | ||
|
||
type S3Storage struct { | ||
ctx context.Context | ||
svc *s3.S3 | ||
svc s3iface.S3API | ||
bucket string | ||
prefix string | ||
unsignedRequests bool | ||
writeACLrule string | ||
} | ||
|
||
func NewS3Storage( | ||
|
@@ -30,6 +32,7 @@ func NewS3Storage( | |
region string, | ||
endpoint string, | ||
unsignedRequests bool, | ||
writeACLrule string, | ||
) (Storage, error) { | ||
log.WithFields(log.Fields{"bucket": bucket, | ||
"prefix": prefix, | ||
|
@@ -52,6 +55,7 @@ func NewS3Storage( | |
bucket: bucket, | ||
prefix: prefix, | ||
unsignedRequests: unsignedRequests, | ||
writeACLrule: writeACLrule, | ||
} | ||
return &backend, nil | ||
} | ||
|
@@ -139,6 +143,13 @@ func (b *S3Storage) Size(pth string) (int64, error) { | |
} | ||
} | ||
|
||
func (b *S3Storage) GetACLWriteRule() string { | ||
if b.writeACLrule == "" { | ||
return s3.ObjectCannedACLPublicRead | ||
} | ||
return b.writeACLrule | ||
} | ||
|
||
func (b *S3Storage) PutFile(pth string, in io.ReadCloser) error { | ||
var buf bytes.Buffer | ||
_, err := buf.ReadFrom(in) | ||
|
@@ -150,7 +161,7 @@ func (b *S3Storage) PutFile(pth string, in io.ReadCloser) error { | |
params := &s3.PutObjectInput{ | ||
Bucket: aws.String(b.bucket), | ||
Key: aws.String(key), | ||
ACL: aws.String(s3.ObjectCannedACLPublicRead), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahhh, I see you changed it here. Is this horizon-light-only code? Otherwise we would need to check whether it breaks something. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, I was wondering the same on usage, it seems like it may be contained to just the AWS Batch account S3 for horizon light ledgerexport? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that ACL has been there since 2017, so, could be used in various ways, @bartekn , do you have insight on types of usages of I think I'm going to revert this line, leave that ACL in to avoid unraveling, and instead add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, I went with that change and added config option to override the S3 File ACL rule applied - 452b20c bucket owner policy works with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good! Will the code still work if we remove ACL support from the bucket? (which is what AWS recommends) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will if client is the bucket owner, and for any other prinicipals that should have access, adding an inline policy on the bucket with allow statements should provide write and read rules, I added such a policy doc to |
||
ACL: aws.String(b.GetACLWriteRule()), | ||
Body: bytes.NewReader(buf.Bytes()), | ||
} | ||
req, _ := b.svc.PutObjectRequest(params) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
during testing with END=0, ran into this as it was stopping before generation anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch