投稿時間:2022-07-18 13:10:09 RSSフィード2022-07-18 13:00 分まとめ(15件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
python Pythonタグが付けられた新着投稿 - Qiita 夜間光データで2016年熊本地震の復興状況を調査してみた https://qiita.com/oz_oz/items/1283ec8501e59570ab8e googlecolab 2022-07-18 12:15:36
python Pythonタグが付けられた新着投稿 - Qiita herokuでのdocker-compose.ymlの参照範囲について https://qiita.com/std-flower/items/31452e3a428355014721 dockercompose 2022-07-18 12:00:55
js JavaScriptタグが付けられた新着投稿 - Qiita SolidJS 使い始めてなんにでも取り入れたい脳の所感 https://qiita.com/KzKousaka/items/e8c1618828b2b3e52329 react 2022-07-18 12:50:24
AWS AWSタグが付けられた新着投稿 - Qiita AWS不正利用から反省したプライベートのセキュリティ意識 https://qiita.com/palao/items/180aec4bbac926fdd79a 請求 2022-07-18 12:14:10
Docker dockerタグが付けられた新着投稿 - Qiita Minecraftサーバーをクロスプレイで運用するまでにやったこと https://qiita.com/mabubu0203/items/59a78b689740b42549c0 minecraft 2022-07-18 12:45:55
Docker dockerタグが付けられた新着投稿 - Qiita herokuでのdocker-compose.ymlの参照範囲について https://qiita.com/std-flower/items/31452e3a428355014721 dockercompose 2022-07-18 12:00:55
海外TECH DEV Community Write your Kubernetes Infrastructure as Go code - cdk8s-plus in action! https://dev.to/abhirockzz/write-your-kubernetes-infrastructure-as-go-code-cdk8s-plus-in-action-58m2 Write your Kubernetes Infrastructure as Go code   cdks plus in action One of my previous blog post covered how to get started with cdks Cloud Development Kit for Kubernetes that is an an open source framework part of CNCF using which you can define your Kubernetes applications using regular programming languages instead of yaml You were able to setup a simple nginx Deployment and accessed it via a Service all this was done using Go which was then converted to yaml using cdks synth and submitted to the cluster using kubectl This was a good start However since the core cdks library is pretty low level for a good reason the code involved lot of boilerplate you can refer to the code here cdks plus leverages building blocks from cdks core library thereby helping reduce verbosity and complexity by providing higher level abstractions APIs for all Kubernetes objects such as Deployments Services etc In this blog we will see cdks plus in action and even deploy Wordpress on Kubernetes with it Let s start by revamping the Nginx deployment To witness how cdks plus works it s best to look at the code It is available on Github I will walk you through the code as we go along func NewNginxChart scope constructs Construct id string props NginxChartProps cdks Chart var cprops cdks ChartProps if props nil cprops props ChartProps chart cdks NewChart scope jsii String id amp cprops dep cdksplus NewDeployment chart jsii String deployment amp cdksplus DeploymentProps Metadata amp cdks ApiObjectMetadata Name jsii String nginx deployment cdks plus dep AddContainer amp cdksplus ContainerProps Name jsii String nginx container Image jsii String nginx Port jsii Number dep ExposeViaService amp cdksplus DeploymentExposeViaServiceOptions Name jsii String nginx container service ServiceType cdksplus ServiceType LOAD BALANCER Ports amp cdksplus ServicePort Port jsii Number TargetPort jsii Number return chart We start by creating a Deployment then add a container and finally expose it using a Service This is quite intuitive and user friendly The container details could have been provided via DeploymentProps but using AddContainer seemed more natural at least to me To generate Kubernetes manifest simply run cdks synth This will generate a yaml in the dist folder Here is an example some of the names labels etc will be different in your case apiVersion apps vkind Deploymentmetadata name nginx deployment cdks plusspec minReadySeconds progressDeadlineSeconds replicas selector matchLabels cdks io metadata addr nginx cdks plus deployment cbe strategy rollingUpdate maxSurge maxUnavailable type RollingUpdate template metadata labels cdks io metadata addr nginx cdks plus deployment cbe spec automountServiceAccountToken true containers image nginx imagePullPolicy Always name nginx container ports containerPort securityContext privileged false readOnlyRootFilesystem false runAsNonRoot false dnsPolicy ClusterFirst securityContext fsGroupChangePolicy Always runAsNonRoot false setHostnameAsFQDN false apiVersion vkind Servicemetadata name nginx container servicespec externalIPs ports port targetPort selector cdks io metadata addr nginx cdks plus deployment cbe type LoadBalancerBoth the Deployment and Service are present in the same manifest since they were declared in the same Chart It s worth noting that there was no need to specify any Pod label selectors template labels in Deployment code or Service selector cdks plus took care of it by auto generating cdks io metadata addr nginx cdks plus deployment cbe which was used in spec selector matchLabels and spec template metadata labels along with the Service selector in nginx container serviceA note on dependenciesgo mod lists all the modules require github com aws constructs go constructs v v github com aws jsii runtime go v github com cdks team cdks core go cdks v v github com cdks team cdks plus go cdksplus v v rc Note that we are using cdksplus The reason for this naming convention is because each cdks plus library is separately vended to target a specific Kubernetes version the at the end signifies that this dependency will work with Kubernetes I would recommend reading the FAQs to get further clarityTo test this locally you can use minikube kind etc git clone cd part cdks plus in action nginx example make sure cluster is runningminikube start create the resourceskubectl apply f dist kubectl get pods wOnce Pod is running check the Service kubectl get svcIn a terminal run this command it runs as a separate process minikube tunnelTo access the nginx server navigate to the external IP as per the Service In the case of minikube you can simply use localhost or How about a Wordpress installation on Kubernetes I like this example it s not overly complex but realistic enough because it has multiple moving parts that includes a combination of stateless stateful components different kinds of services etc This post is not a deep dive into Wordpress and loosely inspired by this article in the Kubernetes documentation which I assume folks might be familiar with The main function will give you a sense of what lies ahead func main app cdks NewApp nil mySQLChart NewMySQLChart app mysql nil wordpressChart NewWordpressChart app wordpress nil wordpressChart AddDependency mySQLChart app Synth So far we have dealt with a single chart Our Wordpress cdks application has two separate charts one for MySQL database and the other one for Wordpress This will result in two different manifests being created as a result of cdks synth process Let s look the MySQL chart firstsome code has been omitted for brevityWe start by defining a Kubernetes Secret to store MySQL password with NewSecret func NewMySQLChart scope constructs Construct id string props MyChartProps cdks Chart secretName mysql pass password Password mysqlSecret cdksplus NewSecret chart jsii String mysql secret amp cdksplus SecretProps Metadata amp cdks ApiObjectMetadata Name jsii String secretName secretKey password mysqlSecret AddStringData jsii String secretKey jsii String password MySQL password has been declared in the code not a best practice by any means just for demo Do not do this in production Then we create the Deployment and provide container details Notice how the Secret has been added as an environment variable to the container First we got an EnvValue using EnvValue FromSecretValueThat was added to the container using Env AddVariable dep cdksplus NewDeployment chart jsii String mysql deployment cdksplus amp cdksplus DeploymentProps containerImage mysql mysqlContainer dep AddContainer amp cdksplus ContainerProps Name jsii String mysql container Image jsii String containerImage Port jsii Number envValFromSecret cdksplus EnvValue FromSecretValue amp cdksplus SecretValue Key jsii String secretKey Secret mysqlSecret amp cdksplus EnvValueFromSecretOptions Optional jsii Bool false mySQLPasswordEnvName MYSQL ROOT PASSWORD mysqlContainer Env AddVariable jsii String mySQLPasswordEnvName envValFromSecret For durable storage we create a PersistentVolumeClaim use that to define a Volume and mount in onto the container at the path var lib mysql mysqlPVC cdksplus NewPersistentVolumeClaim chart jsii String mysql pvc amp cdksplus PersistentVolumeClaimProps AccessModes amp cdksplus PersistentVolumeAccessMode cdksplus PersistentVolumeAccessMode READ WRITE ONCE Storage cdks Size Gibibytes jsii Number mysqlVolumeName mysql persistent storage mysqlVolume cdksplus Volume FromPersistentVolumeClaim chart jsii String mysql vol pvc mysqlPVC amp cdksplus PersistentVolumeClaimVolumeOptions Name jsii String mysqlVolumeName mySQLVolumeMountPath var lib mysql mysqlContainer Mount jsii String mySQLVolumeMountPath mysqlVolume amp cdksplus MountOptions Finally we create a Service mySQLServiceName mysql service clusterIPNone None cdksplus NewService chart jsii String mysql service amp cdksplus ServiceProps Metadata amp cdks ApiObjectMetadata Name jsii String mySQLServiceName Selector dep ClusterIP jsii String clusterIPNone Ports amp cdksplus ServicePort Port jsii Number Unlike previous example we create a Service explicitly and then refer to Deployment object in the service selector Wordpress Chart Except for minor differences it s the same as the MySQL chart with Wordpress specific configuration obviously So I won t repeat it here feel free to explore the code The moment of truth is here Rinse and repeat cdks synth to create the manifest and apply it with kubectl cd part cdks plus in action wordpress create manifestscdks synth apply themkubectl apply f dist output you will see something similar to secret mysql pass createddeployment apps mysql mysql deployment cdksplus cd createdpersistentvolumeclaim mysql mysql pvc cbba createdservice mysql service createddeployment apps wordpress wordpress deployment cdksplus cda createdservice wordpress service createdpersistentvolumeclaim wordpress wordpress pvc ca createdIn a different terminal run if not already running minikube tunnelUse your browser to navigate to http localhost You should see the familiar Wordpress installation screen Go ahead finish the installation and log into your Wordpress instance Feel free to experiment Maybe try deleting the MySQL deployment and re creating it Thanks to the PersistentVolume MySQL data should be recovered and wordpress will continue to work ConclusionAwesome In this blog you saw the expressiveness of cdks plus We started off with a compact and less verbose version of the Nginx deployment and ended up with a full fledged Wordpress instance all using Go Happy coding 2022-07-18 03:22:58
海外TECH DEV Community JavaScript Interview Coding Test Problem 8 https://dev.to/stormytalent/javascript-interview-coding-test-problem-8-4c4i JavaScript Interview Coding Test Problem Learn how to create a queue when the only data structure you have access to is a stack InstructionsWrite a function that creates a queue using two stacks Besides these twD stacks you may not use any additional data structures in your implementation It should have the methods enqueue dequeue and s ize Feel free to change the code provided below when you start It s meant to be a guide Solution class Queue constructor this enqueueStorage this dequeueStorage enqueue tem this enqueuestorage push item dequeue if this dequeueStorage length return this dequeueStorage pop f ths enqueuetorage ength while this enqueuetorage length this dequeuestorage push this enqueuetorage pop return this dequeueStorage pop console warn Attempting to dequeue from an empty queue return undefined How it WorksWe have two storage stacks this enqueueStorage andthis dequeuestorage To see how they interact let s go thrDugh an example EnqueuingWe want to put elements onto the queue and s We enqueueall of these and they all go into enqueuestorage enqueuestorage dequeuestorage We now want to dequeue an item Let s dive into our dequeue function DequeuingWe skip the if statement on line since dequeuestorage is empty We moveon to line Inside that if statement line we pop every item off of enqueuestorage and put them into dequeuestorage When the while loop lines is finished enqueuestorage is empty and dequeuestorage has the five items but in reverse enqueuestorage dequeuestorage On line we pop dequeuestorage and return the item i enqueuestorage dequeuestorage If we want to dequeue again we can enter the dequeue method once more This time we go into the first if statement and pop an item off of dequeuestorage and return it enqueuestorage dequeuestorage We can keep dequeuing if we like As long as dequeuestorage has items in it the last item will be popped off and returned to us SummaryThese steps together make it so our queue functions properly Enqueuing pushes items onto one stack Dequeuing pops them from the second stack When the second stack is empty and we want to dequeue we empty the first stack onto the second reversing the order of items Enqueue TimeEvery enqueue event is a simple push onto a stack This means that each enqueue has a time complexity of Dequeue TimeSo for most cases we have o and for a few rare cases we have o n We can merge these into a single time complexity Queue LifecycleLet s track the life of three items in our queue Starting with an empty queue let s enqueue i and This puts them on our first stack enqueuestorage dequeuestorage So far we ve performed operations inserting each of those items onto the stack Let s dequeue all three items First all items from enqueuestorage gettransferred to dequeuestorage enqueuestorage dequeuestorage We ll say that a transference is Dperation This is another operatiDns total bringing us up to 2022-07-18 03:09:21
海外TECH DEV Community Notify users when a new version of your site is available and prompt them to refresh the page. https://dev.to/akimyou/notify-users-when-a-new-version-of-your-site-is-available-and-prompt-them-to-refresh-the-page-5cj7 2022-07-18 03:01:07
海外ニュース Japan Times latest articles Japan looks to balance no COVID restrictions with growing strain on hospitals https://www.japantimes.co.jp/news/2022/07/18/national/science-health/covid-medical-care/ Japan looks to balance no COVID restrictions with growing strain on hospitalsThe government is facing a two pronged challenge of preventing the medical system from being overwhelmed while at the same time keeping society running as normal 2022-07-18 12:43:55
海外ニュース Japan Times latest articles PSG arrives in Japan for three-game tour https://www.japantimes.co.jp/sports/2022/07/18/soccer/psg-in-japan/ gamba 2022-07-18 12:26:19
ニュース BBC News - Home Heatwave: More evacuations as Mediterranean wildfires spread https://www.bbc.co.uk/news/world-europe-62196045?at_medium=RSS&at_campaign=KARANGA greece 2022-07-18 03:20:09
ニュース BBC News - Home World Athletics Championships: Shelly-Ann Fraser-Pryce wins 100m https://www.bbc.co.uk/sport/av/athletics/62202035?at_medium=RSS&at_campaign=KARANGA World Athletics Championships Shelly Ann Fraser Pryce wins mShelly Ann Fraser Pryce wins her fifth women s m gold at the World Athletics Championships as Shericka Jackson and Elaine Thompson Herah complete a Jamaican clean sweep of the medals with Great Britain s Dina Asher Smith finishing fourth 2022-07-18 03:34:41
ニュース BBC News - Home World Athletics Championships: Dina Asher-Smith says fourth place in 100m final 'sucks' https://www.bbc.co.uk/sport/av/athletics/62201922?at_medium=RSS&at_campaign=KARANGA World Athletics Championships Dina Asher Smith says fourth place in m final x sucks x Great Britain s Dina Asher Smith says it sucks to finish fourth in the m final at the World Athletics Championships despite equalling her own British record of seconds 2022-07-18 03:30:19
北海道 北海道新聞 乗用車が路外逸脱、女性死亡 旭川 https://www.hokkaido-np.co.jp/article/707063/ 逸脱 2022-07-18 12:23:05

コメント

このブログの人気の投稿

投稿時間:2021-06-17 22:08:45 RSSフィード2021-06-17 22:00 分まとめ(2089件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)