100% found this document useful (3 votes)
47 views

Kubernetes Programming with Go: Programming Kubernetes Clients and Operators Using Go and the Kubernetes API 1st Edition Philippe Martin All Chapters Instant Download

Clients

Uploaded by

neiszilanos9
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
47 views

Kubernetes Programming with Go: Programming Kubernetes Clients and Operators Using Go and the Kubernetes API 1st Edition Philippe Martin All Chapters Instant Download

Clients

Uploaded by

neiszilanos9
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Get ebook downloads in full at ebookmeta.

com

Kubernetes Programming with Go: Programming


Kubernetes Clients and Operators Using Go and the
Kubernetes API 1st Edition Philippe Martin

https://ebookmeta.com/product/kubernetes-programming-with-
go-programming-kubernetes-clients-and-operators-using-go-
and-the-kubernetes-api-1st-edition-philippe-martin-2/

OR CLICK BUTTON

DOWNLOAD NOW

Explore and download more ebook at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Kubernetes Programming with Go: Programming Kubernetes


Clients and Operators Using Go and the Kubernetes API 1st
Edition Philippe Martin
https://ebookmeta.com/product/kubernetes-programming-with-go-
programming-kubernetes-clients-and-operators-using-go-and-the-
kubernetes-api-1st-edition-philippe-martin/
ebookmeta.com

Kubernetes: Preparing for the CKA and CKAD Certifications


Martin

https://ebookmeta.com/product/kubernetes-preparing-for-the-cka-and-
ckad-certifications-martin/

ebookmeta.com

Nonsequential and Distributed Programming with Go.


Christian Maurer

https://ebookmeta.com/product/nonsequential-and-distributed-
programming-with-go-christian-maurer/

ebookmeta.com

Japan Occupied: Survival of Academic Freedom 1st Edition


Ruriko Kumano

https://ebookmeta.com/product/japan-occupied-survival-of-academic-
freedom-1st-edition-ruriko-kumano/

ebookmeta.com
Complex Sport Analytics 1st Edition Felix Lebed

https://ebookmeta.com/product/complex-sport-analytics-1st-edition-
felix-lebed/

ebookmeta.com

Aviation Week Space Technology September 26 October 9


Volume 184 Number 19 2022 1st Edition Collective Of
Authors
https://ebookmeta.com/product/aviation-week-space-technology-
september-26-october-9-volume-184-number-19-2022-1st-edition-
collective-of-authors/
ebookmeta.com

Talent Management in Practice An Integrated and Dynamic


Approach 1st Edition Marian Thunnissen

https://ebookmeta.com/product/talent-management-in-practice-an-
integrated-and-dynamic-approach-1st-edition-marian-thunnissen/

ebookmeta.com

Religion of Democracy An Intellectual Biography of Gerald


Birney Smith 1868 1929 1st Edition W. Creighton Peden

https://ebookmeta.com/product/religion-of-democracy-an-intellectual-
biography-of-gerald-birney-smith-1868-1929-1st-edition-w-creighton-
peden/
ebookmeta.com

Revisiting Sexualities in the 21st Century 1st Edition


Constantinos N Phellas

https://ebookmeta.com/product/revisiting-sexualities-in-the-21st-
century-1st-edition-constantinos-n-phellas/

ebookmeta.com
The Rust Programming Language 2nd Edition Steve Klabnik

https://ebookmeta.com/product/the-rust-programming-language-2nd-
edition-steve-klabnik/

ebookmeta.com
Philippe Martin

Kubernetes Programming with Go


Programming Kubernetes Clients and Operators
Using Go and the Kubernetes API
Philippe Martin
Blanquefort, France

ISBN 978-1-4842-9025-5 e-ISBN 978-1-4842-9026-2


https://doi.org/10.1007/978-1-4842-9026-2

© Philippe Martin 2023

This work is subject to copyright. All rights are solely and exclusively
licensed by the Publisher, whether the whole or part of the material is
concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in
any other physical way, and transmission or information storage and
retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed.

The use of general descriptive names, registered names, trademarks,


service marks, etc. in this publication does not imply, even in the
absence of a specific statement, that such names are exempt from the
relevant protective laws and regulations and therefore free for general
use.

The publisher, the authors, and the editors are safe to assume that the
advice and information in this book are believed to be true and accurate
at the date of publication. Neither the publisher nor the authors or the
editors give a warranty, expressed or implied, with respect to the
material contained herein or for any errors or omissions that may have
been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.

This Apress imprint is published by the registered company APress


Media, LLC, part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY
10004, U.S.A.
To Mélina and Elsa, my constant source of truth
Introduction
Back in 2017, I was working for a company building video streaming
software. At the end of that year, a small team, including me, got
assigned a new job to work on deploying the Video CDN developed by
the company on Kubernetes. We decided to explore the concept of
Custom Resources and Operators to deploy this CDN.
The current Kubernetes release was 1.9, the concept of Custom
Resource Definition had just been released in 1.7, and the sample-
controller repository was the only documentation we knew of to help
build an Operator. The Kubernetes ecosystem, being especially lively,
had tools appearing in the following months, specifically the
Kubebuilder SDK. Thus, our project was launched.
From that moment on, I spent numerous days exploring how to
build Operators and other programs interacting with the Kubernetes
API. But the damage was done: I had started to learn Kubernetes
programming from specific to general, and it took me a long time to
fully understand the innards of the Kubernetes API.
I have written this book in the hope that it can teach new
Kubernetes developers how to program, from general to specific, with
the Kubernetes API in Go.

Chapters at a Glance
The target reader for this book has some experience working with
REST APIs, accessing them either by HTTP or using clients for specific
languages; and has some knowledge of the Kubernetes platform,
essentially as a user—for example, some experience deploying such
APIs or frontend applications with the help of YAML manifests.
Chapter 1 of the book explores the Kubernetes API and how it
implements the principles of REST. It especially focuses on the
Group-Version-Resource organization and the Kind concept
proposed by the API.
Chapter 2 continues by covering the operations proposed by the API
and the details of each operation, using the HTTP protocol.
Chapters 3 to 5 describe the common and “low-level” Go libraries to
work with the Kubernetes API: the API and API Machinery Libraries.
Chapters 6 and 7 cover the Client-go Library—the high-level library
to work with the Kubernetes API in Go—and how to unit test code
using this library.
At this point in the book, the reader should be comfortable with
building Go applications working with native resources of the
Kubernetes API.
Chapters 8 and 9 introduce the concept of Custom Resources and
how to work with them in Go.
Chapters 10 to 12 cover the implementation of Kubernetes Operators
using the controller-runtime library.
Chapter 13 explores the Kubebuilder SDK, a tool to help develop and
deploy Kubernetes Operators.
By the end of the book, the reader should be able to start building
Kubernetes operators in Go and have a very good understanding of
what happens behind the scenes.
Any source code or other supplementary material referenced by the
author in this book is available to readers on GitHub via the book's
product page, located at https://github.com/Apress/Kubernetes-
Programming-with-Go-by-Philippe-Martin. For more detailed
information, please visit http://www.apress.com/source-code.
Acknowledgments
I would like to thank the whole Anevia “CDN” team who started
working with me on Kubernetes back in 2018: David, Ansou, Hossam,
Yassine, É tienne, Jason, and Michaël. Special thanks to Damien Lucas for
initiating this project and for having trusted us with this challenge.
My discovery of Kubernetes has been much easier and pleasant
thanks to the TGIK channel and its numerous episodes, hosted by Joe
Beda, Kris Nova, and many others. Plus, thanks to all the Kubernetes
community for such a great ecosystem!
Table of Contents
Chapter 1:​Kubernetes API Introduction
Kubernetes Platform at a Glance
OpenAPI Specification
Verbs and Kinds
Group-Version-Resource
Sub-resources
Official API Reference Documentation
The Deployment Documentation
Operations Documentation
The Pod Documentation
One-Page Version of the Documentation
Conclusion
Chapter 2:​Kubernetes API Operations
Examining Requests
Making Requests
Using kubectl as a Proxy
Creating a Resource
Getting Information About a Resource
Getting the List of Resources
Filtering the Result of a List
Deleting a Resource
Deleting a Collection of Resources
Updating a Resource
Managing Conflicts When Updating a Resource
Using a Strategic Merge Patch to Update a Resource
Applying Resources Server-side
Watching Resources
Filtering During a Watch Session
Watching After Listing Resources
Restarting a watch Request
Allowing Bookmarks to Efficiently Restart a watch Request
Paginating Results
Getting Results in Various Formats
Getting Results as a Table
Using the YAML Format
Using the Protobuf Format
Conclusion
Chapter 3:​Working with API Resources in Go
API Library Sources and Import
Content of a Package
types.​go
register.​go
doc.​go
generated.​pb.​go and generated.​proto
types_​swagger_​doc_​generated.​go
zz_​generated.​deepcopy.​go
Specific Content in core/​v1
ObjectReference
ResourceList
Taint
Toleration
Well-Known Labels
Writing Kubernetes Resources in Go
Importing the Package
The TypeMeta Fields
The ObjectMeta Fields
Spec and Status
Comparison with Writing YAML Manifests
A Complete Example
Conclusion
Chapter 4:​Using Common Types
Pointers
Getting the Reference of a Value
Dereferencing a Pointer
Comparing Two Referenced Values
Quantities
Parsing a String as Quantity
Using an inf.​Dec as a Quantity
Using a Scaled Integer as a Quantity
Operations on Quantities
IntOrString
Time
Factory Methods
Operations on Time
Conclusion
Chapter 5:​The API Machinery
The Schema Package
Scheme
Initialization
Mapping
Conversion
Serialization
RESTMapper
Kind to Resource
Resource to Kind
Finding Resources
The DefaultRESTMappe​r Implementation
Conclusion
Chapter 6:​The Client-go Library
Connecting to the Cluster
In-cluster Configuration
Out-of-Cluster Configuration
Getting a Clientset
Using the Clientset
Examining the Requests
Creating a Resource
Getting Information About a Resource
Getting List of Resources
Filtering the Result of a List
Setting LabelSelector Using the Labels Package
Setting Fieldselector Using the Fields Package
Deleting a Resource
Deleting a Collection of Resources
Updating a Resource
Using a Strategic Merge Patch to Update a Resource
Applying Resources Server-side with Patch
Server-side Apply Using Apply Configurations
Building an ApplyConfigurati​on from Scratch
Building an ApplyConfigurati​on from an Existing Resource
Watching Resources
Errors and Statuses
Definition of the metav1.​Status Structure
Error Returned by Clientset Operations
RESTClient
Building the Request
Executing the Request
Exploiting the Result
Getting Result as a Table
Discovery Client
RESTMapper
PriorityRESTMapp​er
DeferredDiscover​yRESTMapper
Conclusion
Chapter 7:​Testing Applications Using Client-go
Fake Clientset
Checking the Result of the Function
Reacting to Actions
Checking the Actions
Fake REST Client
FakeDiscovery Client
Stubbing the ServerVersion
Actions
Mocking Resources
Conclusion
Chapter 8:​Extending Kubernetes API with Custom Resources
Definitions
Performing Operations in Go
The CustomResourceDe​finition in Detail
Naming the Resource
Definition of the Resource Versions
Converting Between Versions
Schema of the Resource
Deploying a Custom Resource Definition
Additional Printer Columns
Conclusion
Chapter 9:​Working with Custom Resources
Generating a Clientset
Using deepcopy-gen
Using client-gen
Using the Generated Clientset
Using the Generated fake Clientset
Using the Unstructured Package and Dynamic Client
The Unstructured Type
The UnstructuredList​Type
Converting Between Typed and Unstructured Objects
Other documents randomly have
different content
XLI
Outside the mission-hall in the gently-raining April night, James
Dodson, with his coat collar turned up over his ears and his hat
pulled down over his eyes, lay in waiting for his friend. Upon
beholding this woe-begone figure William Jordan gave a start of
surprise.
“Why, Jimmy,” he said, “why do you come here now?”
“As I was half-way through the performance at the Alcazar,” said
Jimmy Dodson apprehensively, “I had a sort of presentiment.
Something seemed to tell me, Luney, that after to-night I might never
see you again. Something seemed to tell me that you were going
away.”
“Nature has certainly spoken to me,” said William Jordan.
“That doesn’t mean, Luney, old boy,” said Jimmy Dodson in a voice
not the least like his own, “that you intend to desert an old friend?”
“To-morrow at dawn I obey her decree,” said William Jordan.
“You don’t mean to say you are going away!” cried Jimmy Dodson.
“Yes—for a little while.”
“But—but,” said Jimmy Dodson, “I don’t think I could bear it if you
were never to come back. You see, Luney, old boy—well, you see—
well, somehow, I can’t explain it—but—if—you—were—never—to—
come—back!”
The voice of Jimmy Dodson was slow-drawn like a wail. It pierced
William Jordan to the heart. Tears leaped to the eyes of the young
man, but in the darkness his stricken companion could not see them.
“Luney,” said Jimmy Dodson, “will you promise that you will come
back?”
“I promise,” said the young man.
“Honour bright, you know, honest Injun,” said Dodson anxiously.
“Honest Injun, Jimmy,” said William Jordan, with a strange smile in
his eyes.
“Give me your hand on it, old boy,” said Jimmy Dodson; “although I
am sure you wouldn’t play it low down on an old pal.”
William Jordan yielded to his friend’s importunity.
Dodson shuddered.
“Why, old boy,” he said, “it is so cold—so cold. Ugh, it is like ice.”
William Jordan kissed his friend in the darkness.
“And—and,” cried Dodson, “your lips burn like a fire.”
The two friends walked along in a silence. After they had proceeded
a long distance in this fashion through the wet midnight streets, the
thin and high-strung tones of Jimmy Dodson were heard again in the
darkness.
“Luney,” he said in a voice that seemed to over-tax his powers of
utterance, “I always used to wonder what made me take up with a
chap like you; but since you came out of prison I have done nothing
but wonder what made you take up with a chap like me.”
“You are one of the links in the chain,” said William Jordan, “one of
the stages in the journey.”
“I don’t understand you at all,” said Jimmy Dodson.
“Perhaps it is well,” said William Jordan.
“And yet you know, old boy,” said Jimmy Dodson, “when I first knew
you, I didn’t understand you then. But I always accounted for it by
the fact that you were not quite all there. Well, I don’t understand you
a bit better now, although I have come now to account for it by the
fact that I am not quite all there. I don’t know why I have come round
towards you like I have. At first I thought you were rather less than
the ordinary, and that you didn’t count at all; but now I consider you
to be the finest chap I’ve ever known, and that you have got
something about you that more than makes up for what you lack.”
“May you not have entered upon another phase?” said William
Jordan.
“I don’t quite know what you mean, old boy,” said Jimmy Dodson,
“unless you mean that I’ve changed. At least I had that kind of
thought as I sat this evening at the Alcazar. The wrestling bored me,
the songs were rotten, and I didn’t think much of the ballet. And I
thought the band was out of tune—all except John Dobbs. In fact, I
began to wonder why I came. And then suddenly I thought of that
night, old boy, when you sat at my side, and I took you round to see
Hermione——”
“Ah, the goddess!” exclaimed William Jordan softly.
“I have often thought since,” said his friend, “that it was not right to
play it on you as we did. And what Hermione said about you
afterwards, old boy, rather turned me against her. But she was pretty
low down, was Hermione; yes, she doesn’t dance in the ballet now-
a-days. All the same she rather knocked you, old boy, didn’t she?”
“I thought her to be divine,” said William Jordan simply.
The two friends stayed their steps under a flickering gas-lamp in the
City. The steady rain continued. The clock of a neighbouring church
told the hour.
“It will be a long and wet walk to Peckham, Jimmy,” said William
Jordan.
“It will, old boy,” said his friend; “but what do you suppose I care, now
that you have given me your promise to come back? By the way, old
boy, do you think it would be asking too much, as a special favour,
for you to write me a line now and then just to say that you are
alive?”
The gaze of William Jordan grew heavy with a darkness that was
veiled from his friend.
“You must forgive me, Jimmy, if I don’t,” he said.
“As a special favour,” pleaded his friend. “You know, old boy, I have
never had a line of yours. I have always been meaning to ask you for
your autograph—that is before the trouble came—and—and now the
trouble has come I intend to ask you for it. Send me a line, old boy,
to say you are alive.”
“I cannot promise to do that,” said William Jordan, “because the
strength has not yet been given to my right hand. But I do promise to
return; and when I do return I shall listen for your tap upon the
shutters; and then I will let you in as far as the threshold of the little
room.”
The friends said their last farewells as the clocks chimed the hour of
two.
XLII
When in the middle of the night, William Jordan regained the little
room, he found the aged man, his father, seated there. The Book
was on the table open. The dagger, the chalice, and the stylus were
also displayed. But in the face of the aged man was the mute
despair which was ever upon it when these articles came to be
brought forth.
The chalice was half-full of the red blood; the quill was dipped
therein and held in the hand. But not a stroke had been committed to
the virgin page of vellum.
“Will it never be done?” said the old man tremulously, “will it never be
accomplished? Answer me, Achilles.”
“I know not, my father,” said the young man. “I am not so learned in
the Book as I once was.”
“Yet our knowledge of the Book increases with our years and our
stature,” said the old man, as if in amazement. “Answer me, Achilles,
is it not so?”
“Yes and no,” said the young man. “The Book of the Ages, my father,
is an expression of the invisible forces of nature. And I am unfit to
discourse thereupon until I have spoken with my mother the Earth,
who is wise and of their kin. As my veins rapidly devour this third and
last phase upon which I am entered, they draw me nearer and
nearer to her. Never have I been so near to her as I am to-night. As
soon as the bright east announces the dawn I go to lie at the soft
brown bosom of my mother. If she will give suck to the first of her
children, perhaps it may be that the strength will come into his right
hand.”
As the young man spoke these words, he walked to the window of
the little room and drew back the shutters.
“I see a faint light in the east,” he said, with a subdued excitement.
“The hour is at hand when I go upon my way.”
“You will return, O Achilles?” said his aged father apprehensively. “I
am lonely and my hairs are white.”
“Yes, my father, I will return,” said William Jordan, “I will return to our
little room. When I have gone out and lain at the breasts of my
mother the Earth; and I have walked in her wildernesses, and I have
traversed her seas, and I have surprised the last of her secrets,
which may be no secrets at all, I will return, my father, to our little
room.”
“That is well, beloved one,” said the aged man, pressing his pale lips
to the forehead of the young man.
Yet in the emotion generated by his words of farewell, the young
man was seized again with a paroxysm.
“What—what do I see upon your lips, Achilles?” cried the aged man,
his father, peering with a curious horror in his dim eyes.
“Nature’s mandate, my father,” said the young man, with his secret
and beautiful smile.
XLIII
As William Jordan went forth of the little room and took his ways, the
east had still no more than a few faint grey flecks, which were hardly
more than vaunt-couriers of the hues of dawn. Into the ruck of the
streets he took his way. He plunged into them headlong, without
calculation, without attempting to discriminate. Yet there was neither
hurry of the flesh nor of the spirit; both were rational, temperate,
responsible.
The rain had ceased; but the black pavements were slippery and
unwholesome, and there was the stench of a thousand drains. Street
after street he passed through at the same regulated pace, which
was neither slow nor fast. Rows upon rows of houses which he had
never seen before came into view; and at last, as all the sky was
bright with the new day, he saw the green lanes, and began to taste
the pure woodland airs.
As soon as he knew himself to be free of the great city, he left the
highways and struck a direct course across the green fields. Over
the hedgerows and across the pastures he bent his steps; across
morasses and through tangled places, not knowing nor desiring to
know whither; past hamlets with thatched roofs, and crooked rustic
churches; past farm steadings; past stately mansions; over upland
and fen, until the sun had reached its zenith in the heavens. He then
sat on the hospitable earth, and for a space rested his weariness on
the fringe of a green wood, in a dry warm place, under a splendid
tree, alive with sap and the melody of birds.
When again he went his way the sun was still high in the April
heaven, though pursuing a steady track towards the west. The
wayfarer followed it in a straight line, over hedgerow and pasture,
sometimes crossing a brook with his naked feet; at other times
leaping a ditch, or breaking through barriers of thorn and timber
which seemed insurmountable.
The wayfarer paid no heed to the miles that he made. As the light of
the sun began to fail, he found himself upon the wealds and uplands,
with the generous sweet-smelling earth ever beneath him. The
evening airs seemed to blow with a sharper sweetness; the houses
and hamlets grew fewer, yet nature’s spontaneity grew ever richer
and more rare.
When it was almost dark he reached a little and solitary house on the
edge of a great wood. It seemed to be interminable, and full of
pungent yet delicately odorous trees. He knocked at the door of the
little house. His summons was answered by an old woman in a grey
shawl; and for a penny she gave him a cake of bread and a cup of
water. He drank the water like one who thirsts; and then he bore his
limbs, which now ached with weariness, into the gloomy precincts of
the wood. Groping about in the darkness, he found a dry and
sheltered place amid the fresh flowering furze; and here, with his
head propped against the bole of a young pine, he ate his food
slowly, and then straightway fell into a profound sleep.
When he awoke the sky was alive with beautiful stars. With all of
these he was familiar. He rose; and by the delicate light of the
heavens, which melted the dark canopies above him, pressed
through the brakes and thickets into the heart of the forest. Many
were the nimble-footed wild creatures that crossed his path, and in
the darkness startled him; he was sensible all about him of weird
cries and wonderful voices; they came upon him from every side; but
he still pressed on and on into the untrodden darkness of the wood.
In his progress his garments were rent and his hands bled freely.
In the process of time, the pathlessness which confronted him
everywhere grew less impenetrable. The dawn crept again into the
east, the birds took up their loud songs, and flowers and herbs and
all the wild things of nature were spread before him in the morning
light.
Pressing ever on and on, he came out at last upon the fringe of this
great wood, and by now the sun had risen to warm his veins. The
wayfarer was now come to the breast of the mighty mother; and on
this second day he reposed many hours on the green, dry earth of
the forest, looking all about him into its dark recesses, and observing
in a kind of secret joy the ways of the rich, wild life of whom he
claimed kinship.
Towards evening he came upon another little house in the heart of
the great wood, and then he remembered that he was hungry. Here
he obtained from another aged woman a hunch of white bread and a
bowl of delicious milk. And then for the second time he lay down and
slept in the heart of the great wood.
Days and days did he pass in his wanderings. Sometimes he was in
the woodland places, sometimes upon the weald. He would lie in the
fallows in the burning afternoon sun; and now and again in the chill
of the night, if he could not find warmth in the thickets, he would
enjoy the protection of a barn or a cowhouse, or, if these were to
seek, he would walk in a joyful silence through the long hours, until
the morning was again in his eyes.
One day in his ceaseless journeying he suddenly beheld the sea. It
was at noon upon a delicious day of midsummer. He ran down to the
beach, with a noble rapture in his veins, and, flinging off his clothes,
he waded out into the cool water. For many days he kept ever by the
side of the sea. He could not forsake that marvellous companion;
and on several occasions, when he found old men in boats upon the
beach, he persuaded them to row him out upon the many-smiling
wilderness.
Even after the summer had waned his wanderings continued. They
bore him into all kinds of wonderful and unexpected places.
Sometimes he found himself in the high and mountainous country;
and here the grandeur, the solitude, and the marvellous hues and
the deep-breathing silences would endue him with the awe of his
inheritance. And wherever he was borne by the irresponsible
passion of his steps, he beheld infinite wonders. He saw great pits
sunk into the bowels of the earth; he saw curious and grimy peoples,
yet it cost him no pang to admit them into all-embracing kinship with
himself, and with the Earth, his mother.
When as the tints of autumn fell about the quiet earth, and he felt the
shrewd airs of the tall mountains of the west, he heard their voices in
such wise in his ears, as never before had addressed them. With a
loud, fervent cry, he flung himself down upon the fruitful brown soil,
and pressed his lips rapturously to the bosom of Earth, his mother.
The wonderful hues of the autumn deepened in their silent rapidity,
until the ruthless winter was come. Then the wayfarer persuaded an
old shepherd to give him his shawl, and clad therein, and moving
ever upon the peaks of the mountains, he came into the north. And
there he learned many of the cunning but simple arts of these wise
mountain peoples—those hardy children who wrested but a reluctant
nourishment from the bare ground.
It was here that, driven by the stress of winter, the wayfarer shared
the hospitality of the fisherman’s hut, the ploughman’s byre, and the
rude hearth of the crofter and the shepherd. It was in these altitudes
that he renewed the garments for his back and the shoes for his feet.
His scant store of pieces of silver had been consumed long ago, but,
like one of his kin in a remote age, he did not fear to beg his bread
from door to door. Now and again he would requite his hosts, who
asked nought in return, as he sat in the chimney-place, warmed by a
fire of peats and a basin of food, with wonderful tales out of the past,
and glorious stories of the youth of the world. And these he would
clothe in such wise that the simple hearts of his friends would swell
with gladness.
He did not fear the snow in the dales, the ice in the burns, nor the
barren and implacable wastes which confronted him everywhere.
Many and curious were the deeds he performed, strange were the
sights that he witnessed. He made acquaintance with the red deer,
and the mountain sheep, and the fowls of the moorland; he learned
to speak every man in his own tongue; and never once in all these
vicissitudes, although he had no piece of silver in his coat, did he
suffer denial.
He was ragged and unkempt; he was almost as frail as a phantom;
his skin was coloured a deep brown by exposure to the weather; his
hair, thick and matted, came down to his shoulders, and his large
and bright eyes seemed to envelop the whole of his face. By the time
the spring came round again, and the cycle of the seasons had
completed itself, he found his feet again upon the yellow shores of
the loud-sounding sea. Yet now he did not linger within its magical
thrall. For a long dormant passion had again begun to stir within him,
and he knew that the hour was near when he must return to the
aged man, his father, and to the little room.
Through the brakes of the green woods through which he passed the
notes of each bird as it sang were as familiar in his ears as the many
and subtle voices of the wind. He could now read the face of the
fruitful Earth, his mother, like an open page. All her sweet little
mysteries he could decipher; he knew the shapes of her trees, the
odours of her flowers, the habits and tracks of all her nimble wild
creatures. Yet in his veins the passion was ever rising; he felt it was
no longer meet for him to tarry. No more did it beseem him to while
away the glad hours with this old gossip. Ere the winter came again
he must return to the streets of the great city, and thence to the
sanctuary in which he was wont to kneel; and to the white-haired
man, his father; and to that other faithful friend who loved him
tenderly.
In the gorgeous heat of the midsummer he found himself again upon
the mountains of the west. But now the passion was mounting hourly
in the veins of the wayfarer, and soon he was to know that it had
claimed as its fuel a portion of his vital power. His frame had never
been so dauntless and so full of a divine vigour; his brain was like a
crystal; but he seemed to know that his power of sight was not what
it was.
Upon these heights of the west he brought his power of vision to the
proof. He found himself again in those altitudes, which previously he
had trod when the hues of autumn were upon them. At that time he
was able to discern clearly the adjacent peaks by which they were
surrounded; yet on this day of midsummer, although the bright sky
was like a mirror of opals, he knew not even their outlines. And he
seemed to divine, by a clear foreknowledge, that all about him would
soon be dark.
Without hurry, and without fear, although the passion was ever
mounting in his veins, the wayfarer turned his eyes to the east,
towards the little sanctuary within the heart of the streets of the great
city. Mile by mile he retraced the well-remembered steps. Although
he could not now discern all that lay about him, as when a
twelvemonth since he trod these ways, for his eyes were no longer
faithful to him; yet, as his unfaltering limbs overcame the brakes and
the thickets, the downs and the pastures, the new and puissant
sense of kinship with the Earth, his mother, endued his veins with the
strength of heroes.
He could hardly see as he walked through the woodland places, but
the joy and the music by which Nature celebrated her noble
freedoms, the pæans of his ever-youthful mother filled his ears. The
loud and deep voice, that was so clear and so heroical, made the
wayfarer nod and smile at her as he took his way. Pressing ever on
and on over hill and dale, through impenetrable fastnesses, by
marsh and stream, he rejoiced aloud in her noble fecundity. “Sing,
goddess, sing,” he chanted continually, “and I will sing to thee!”
The heart of the wayfarer was entranced with gladness as he
begged his bread from door to door. And as he came nearer and
nearer to the streets of the great city, he began to sing to the Earth,
his mother, in a wonderful kind of speech which he knew was
pleasant to her ear. And she requited him with her own resonant and
golden music, those strange, rapt cadences of her own childlike
voice; and these cradled him in sleep, and he dreamed by the wise
and gracious light of the stars.
“Kiss me, ever young and gentle one,” he whispered to her, as one
evening he lay down on the dry mosses of an autumnal wood. “I can
scarce see thee now, my mother,” he said as he turned his eyes
towards the bole of a great tree, under whose wide-spreading
branches he lay; “but thy ample speech was never so great in my
veins. To-night I shall dream of thee constantly, sweet and gentle
virgin which hath had strange issue.”
As he lay that night asleep under the great tree, the voice of the
Earth, his mother, breathed in his ears. “Return, O Achilles,” it said,
“to the streets of the great city, without another instant of tarrying, for
in my tenderness for thee, thou brave one, I have endowed thy right
hand with strength.”
These words awoke the wayfarer. He arose and knelt before the
gnarled trunk of the great tree which had been the pillow of his
dreams. Pressing his eyes to the green moss over which the ages
had passed, he said joyfully, “I heed thee, my mother. Thou who hast
lain with the stars in their courses, I will bear myself as the fruit of thy
caresses.”
The wayfarer drove the pains of sleep from his limbs, and turned his
dim eyes towards the east.
“Achilles, thy son, heeds thee, my mother,” he said as the bracken
began to yield to his steps; “he will not tarry until he has made the
streets of the great city, so that when he returns into sanctuary he
may find the strength in his right hand.”
With bold and quick steps, as light as those of a deer, the wayfarer
went his way through the chill dawn. When he came out into the
beautiful expanse of the fields, the east shone with morning.
His feet unconsciously sought the well-remembered tracks of his
previous way. The will seemed not to direct the steps of the wayfarer,
yet not once did they stray from the path upon which formerly they
had come. At noon the weather turned bitterly inclement. The winds
blew piercingly from every quarter, and presently the first flakes of
the winter’s snow were shaken out of the adverse heavens. But the
wayfarer pressed on and on into the very teeth of the gale. Asking
neither shelter nor refreshment, his frame, in its puissance,
consumed the miles, for he feared lest the sight of his eyes should
desert him ere he could cross the threshold of the sanctuary that
awaited him and the strength he bore in his right hand.
As the sombre light of the afternoon was waning his feet were once
more upon the pavements of the streets of the great city. The wind
whistled round the corners of the gaunt houses; the air was
thickened by gusts of sleet, which pierced his skin, and stung his
frame to new endeavours.
He recalled all the objects he passed with a strange kind of
exaltation; the houses and shops that he could so indistinctly see;
the hurrying crowds of people in the streets—the “street-persons” of
his childhood, who were “street-persons” no more. The roar of the
traffic filled his surprised ears, yet only to enkindle them with a high
and grave joy; for it was another manifestation of that to which his
whole being owed its entrancement, the universal voice of the Earth,
his mother.
XLIV
The lamps were being lighted in the streets, yet he could hardly see
them. Not once, however, did his feet stray from the path of his well-
remembered way.
With the autumnal sleet ever beating upon his bared head, he found
himself again in the streets of the great city. On the threshold of a
public-house, flaring with many garish lights, he saw a boy selling
matches. He was whimpering with the cold, and his teeth were
chattering, for he had neither shoes nor stockings; indeed, his only
garments were a pair of ragged trousers and a shirt. As the wayfarer
discerned this unhappy figure he stayed his steps, and, pulling off his
own broken boots and threadbare stockings, bade the boy sit down
and put them on. When the boy had obeyed, the wayfarer took from
his own shoulders the shepherd’s shawl which he wore, and
wrapped it about him.
Thereafter it was in the scantiest of raiment that he took his way. Yet
ere he had come to the threshold of the little room, which he seemed
only to have left the day before yesterday, he was destined to take
part in a curious adventure.
It happened as he turned into a familiar thoroughfare, a street long
and narrow, and wondrously busy with a great press of people and
traffic, that he suddenly became aware of a strange clamour that
was arising before him. Cries of consternation resounded on every
side; they overcame the shrieks of the piercing winds as they swept
round the houses and shops. With his dim eyes the wayfarer could
perceive the drivers of the vehicles make frantic efforts to escape
from an oncoming danger that threatened them.
Suddenly there came through the failing light of the afternoon the
great form of a horse, a huge animal attached to a heavy railway
van. There was no driver, the reins were dangling loose; with tossing
mane and wild nostrils, the mighty horse was devouring the roadway
with furious strides. It escaped a tramcar as by a miracle; it crashed
into a milk-seller’s cart, and sent milk-cans with their contents rolling
in all directions. Yet still it kept its course unchecked, a menace to all
whom it passed.
The passers-by, huddling together as far away from the kerb as they
could squeeze themselves, were then astonished by a strange sight.
A ragged, half-naked beggar, hatless, coatless, without shoes and
stockings, and with long, matted hair which fell down upon his
shoulders, moved off the pavement. He appeared to turn his back
upon the mad thing that was approaching him, and then, with a leap
of superhuman courage and address, seemed to fling himself at the
head of the infuriated brute as it grazed his bare ankles with its
hoofs. He was seen to take the reins in his grasp, and, leaping along
at the side of the horse, began an attempt to control its furious speed
that was little short of miraculous. In the struggle he was several
times carried completely off his feet, and borne yards at a time
without touching the earth. And though man and brute and vehicle
swayed and rocked in all directions, no obstacles intervened to
shatter them; and at almost every yard he was borne the man
seemed to gain a firmer purchase on the brute.
For half the length of the thoroughfare the titanic struggle was waged
between the man and the brute on the slippery, circumscribed and
narrow road. At times it seemed that the man must be hurled away
from the brute altogether; at other times it seemed that he must be
flung beneath the hoofs of the brute and trampled lifeless; while,
again, in the frantic efforts of the animal to be rid of its burden, it
seemed that they must both be hurled through the windows of the
shops.
Ere long, however, the fury of the horse began to spend itself. And
as it did so, with the man still retaining his grasp of the reins, two
policemen, stalwart and hardy, and finely-grown men, stepped from
the pavement, and, lending their aid at a timely moment, the poor
animal was brought under control.
“Well done, my lad,” said the policemen to the half-naked beggar in a
kind of generous wonder. “Well done, well done! Are you sure you
are all right?”
Among the witnesses of the incident was a tall, bronzed man, with
closely-cropped hair, who was dressed with remarkable care, and
whose bearing was that of a soldier. At his side was a slight,
youthful, handsome woman, who was breathless with excitement.
“Upon my word,” said the man, “that is the best thing I ever saw.
That chap deserves a medal.”
The woman, with a strange, dancing brightness in her eyes, looked
up wistfully into the face of her companion. “Get him one,” she said.
Stimulated by their generous curiosity, they walked up to the spot
where a small crowd was rapidly collecting around the unkempt and
extraordinary figure that was almost naked.
“Better take his name and address,” said the tall, bronzed man to the
two police constables in a slow and calm voice which caused them
to touch their helmets.
The tall, bronzed man then proceeded to survey the circle of
interested bystanders at a dignified leisure, and said in the same
tone, “Suppose we send round the hat?”
Removing his own immaculately-ironed silk head-gear, he
proceeded with an air of exaggerated self-possession, which the
conspiracy of the circumstances rendered bizarre, to drop several
pieces of gold into its interior, and then, standing bare-headed, so
that the sleet glistened upon the pomatum of his hair, handed his hat
to a man near to him, who was of a similar type to himself. However,
while this gentleman, also with extraordinary nonchalance, was
adding further pieces of gold to the hat, this somewhat impressive
munificence was frustrated.
The half-naked beggar appeared suddenly to realize that he was the
cynosure of all eyes. He gave a gaunt look all about him, and then,
with a motion of indescribable rapidity, he passed through the ring
that had been formed. With a swiftness so great that his flight could
hardly be followed, the mists of the evening received him.
The bare-headed man gave a glance of courteous deprecation,
which almost took the form of a personal apology, to the man who
was placing pieces of gold in his hat.
“Rather a pity,” he said; “rather a pity to let him go.”
“Yes, a pity,” said the other, wiping a speck of sleet off the brim of the
hat very carefully with his glove, and handing it back.
As with an air of disappointment the crowd dispersed reluctantly, the
slight, youthful, handsome woman turned with an eager gesture to
the owner of the hat. Her cheeks, under their powder, were the
colour of snow.
“Did you—did you see his face?” said she in quick, nervous accents.
“I shall carry it to my grave. It was—it was the most beautiful face in
the world.”
The owner of the hat gave the woman a little smile of affectionate
indulgence, in which, however, pride was uppermost, and handed
her very carefully into a hansom.
XLV
As the bare-footed beggar passed away into the traffic, far from the
circle of the curious, before they could impede him, he was able to
discern that his thin hands had been lacerated by the reins during
the struggle he had waged with the horse. The blood was flowing
freely from his torn fingers, but at the sight of it a flush of gladness
overspread his cheeks.
“I thank thee, Mighty One,” he said, “that thou hast given the strength
to my right hand.”
It was with bruised and numbed feet that the returned wayfarer came
at last to the threshold of the little room.
The aged man, his father, gave a cry of joy when he beheld the
apparition that had entered, for, dim as his eyes were, he knew it for
the form of one.
The old and the young man embraced one another.
“I have been desolate, Achilles,” said the old man with the
plaintiveness of age; “I have been desolate. But I knew, O Achilles,
that thou wouldst return.”
A brave fire was burning upon the hearth, the candles, also, were
bright of lustre in the little room.
The young man stretched his wounded hands to the warmth, and
then, with a kind of composed passion, he spread them out before
his father.
“Dost thou see, my father?” he said. “Earth, my mother, has given
the strength to my right hand. I think now, my father, I shall be
among the English authors.”
As he spoke the secret and beautiful smile crept across his wan lips.
“Thou wilt write in the Book, O Achilles?” said the old man, pointing
to the table where the mighty tome lay open.
“First, I must write my little treatise upon human life, my father,” said
the returned wayfarer in the simple accents of his childhood. “And,
perchance, my father, when that is written, if the strength is still given
to my right hand, I may, or I may not, write in the Book.”
“I myself have not yet written in it, O Achilles,” said the aged man,
his father, with a look of despair. “And I begin to fear that it may not
be given to me to write therein. I am old, Achilles; I am old.”
The young man appeared hardly to heed the words of his aged
father.
“I will eat,” he said, “and then until midnight is told upon the clocks I
will repose, and then I will write my little treatise upon human life.”
Half-naked and unkempt and bare-footed as he was, the returned
wayfarer ate and drank; and he then fell asleep in a chair at the side
of the bright hearth with his feet stretched out before the embers.
While the returned wayfarer slept profoundly, the aged man, his
father, heaped up the fire with coals. Then he went forth into the
shop, and took from its recesses the materials for writing.
As the old man was conveying these articles, with every precaution
that he might not disturb the sleeper, to the table of the little room, he
heard a stealthy knocking, with which he had grown familiar, upon
the outer shutters of the shop.
Therefore, as soon as the old man had discharged his burdens, he
went to the door of the shop and opened it. Upon the outer threshold
was a small, wizened man with a shrewd countenance and a short,
bristling moustache.
“Has he come back?” asked the man with an eager whisper.
“Yes, he has returned,” said the old man; “but he now sleeps.”
“Let me see him,” said the other in a voice of anguish. “I will not
disturb his sleep, and I will not try to cross the threshold of your little
room.”

You might also like